org.compass.gps.device.hibernate.entities
Class DefaultHibernateEntitiesLocator

java.lang.Object
  extended by org.compass.gps.device.hibernate.entities.DefaultHibernateEntitiesLocator
All Implemented Interfaces:
HibernateEntitiesLocator

public class DefaultHibernateEntitiesLocator
extends Object
implements HibernateEntitiesLocator

A default implemenation that automatically locates entities to index based on Hibernate current mapped objects and mappings for the objects that exists with Compass.

Author:
kimchy

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
DefaultHibernateEntitiesLocator()
           
 
Method Summary
 EntityInformation[] locate(SessionFactory sessionFactory, HibernateGpsDevice device)
          Locates the entities used for the index operation.
protected  boolean shouldFilter(String entityname, ClassMetadata classMetadata, Map allClassMetaData, HibernateGpsDevice device)
          Returns true if the entity name needs to be filtered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log
Constructor Detail

DefaultHibernateEntitiesLocator

public DefaultHibernateEntitiesLocator()
Method Detail

locate

public EntityInformation[] locate(SessionFactory sessionFactory,
                                  HibernateGpsDevice device)
                           throws HibernateGpsDeviceException
Description copied from interface: HibernateEntitiesLocator
Locates the entities used for the index operation.

Specified by:
locate in interface HibernateEntitiesLocator
Parameters:
sessionFactory - The SessionFactory to be optionally used for locating the entities.
device - The Hibernate device that called this locator.
Returns:
An array of the enteties that need to be indexed during the index operation.
Throws:
HibernateGpsDeviceException

shouldFilter

protected boolean shouldFilter(String entityname,
                               ClassMetadata classMetadata,
                               Map allClassMetaData,
                               HibernateGpsDevice device)
Returns true if the entity name needs to be filtered.

Implementation filteres out inherited hibernate mappings, since the select query for the base class will cover any inherited classes as well.

Note, that this method is called after it has been verified that the class has Compass mappings (either directly, or indirectly by an interface or a super class).

Parameters:
entityname - The name of the entity
classMetadata - The Hibernate class meta data.
device - The Hibernate Gps device
Returns:
true if the entity should be filtered out, false if not.


Copyright (c) 2004-2008 The Compass Project.