org.compass.gps.device.hibernate
Class HibernateGpsDevice
java.lang.Object
org.compass.gps.device.AbstractGpsDevice
org.compass.gps.device.support.parallel.AbstractParallelGpsDevice
org.compass.gps.device.hibernate.HibernateGpsDevice
- All Implemented Interfaces:
- CompassGpsDevice, MirrorDataChangesGpsDevice, PassiveMirrorGpsDevice
public class HibernateGpsDevice
- extends AbstractParallelGpsDevice
- implements PassiveMirrorGpsDevice
A Hibernate Gps Device.
The hibernate device provides support for using jpa to index a database. The path can
be viewed as: Database <-> Hibernate <-> Objects <-> Compass::Gps
<-> Compass::Core (Search Engine). What it means is that for every object that has both
Hibernate and compass mappings, you will be able to index it's data, as well as real time mirroring of
data changes.
When creating the object, a SessionFactory must be provided to the Device.
Indexing uses HibernateEntitiesLocator to locate all the entities that can be
indexed (i.e. entities that have both Compass and Hibernate mappings). The default implementaion
used it the DefaultHibernateEntitiesLocator.
The indexing process itself is done through an implementation of
HibernateIndexEntitiesIndexer. It has two different implementation, the
PaginationHibernateIndexEntitiesIndexer and the
ScrollableHibernateIndexEntitiesIndexer. The default
used is the scrollable indexer.
Mirroring is done by injecting lifecycle listeners into Hibernate. It is done using
HibernateEntityLifecycleInjector with
a default implementation of DefaultHibernateEntityLifecycleInjector
when using Hibernate version < 3.2.6 and DefaultHibernateEntityCollectionLifecycleInjector
when using Hibernate version >= 3.2.6.
Mirroring can be turned off using the setMirrorDataChanges(boolean) to false.
It defaults to true.
The device allows for NativeHibernateExtractor to be set,
for applications that use a framework or by themself wrap the actual
SessionFactory implementation.
The device extends the parallel device provinding supprot for parallel indexing.
- Author:
- kimchy
| Methods inherited from class org.compass.gps.device.AbstractGpsDevice |
buildMessage, getGps, getName, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, refresh, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, stop |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.compass.gps.CompassGpsDevice |
getGps, getName, index, injectGps, isPerformingIndexOperation, isRunning, refresh, setName, shouldMirrorDataChanges, start, stop |
HibernateGpsDevice
public HibernateGpsDevice()
HibernateGpsDevice
public HibernateGpsDevice(String name,
SessionFactory sessionFactory)
doStart
protected void doStart()
throws CompassGpsException
- Description copied from class:
AbstractGpsDevice
- Derived devices can implement it in case of start event notification.
- Overrides:
doStart in class AbstractGpsDevice
- Throws:
CompassGpsException
doStop
protected void doStop()
throws CompassGpsException
- Description copied from class:
AbstractGpsDevice
- Derived devices can implement it in case of stop event notification.
- Overrides:
doStop in class AbstractGpsDevice
- Throws:
CompassGpsException
doGetIndexEntities
protected IndexEntity[] doGetIndexEntities()
throws CompassGpsException
- Description copied from class:
AbstractParallelGpsDevice
- Returns all the indexed entities for this device.
- Specified by:
doGetIndexEntities in class AbstractParallelGpsDevice
- Throws:
CompassGpsException
doGetIndexEntitiesIndexer
protected IndexEntitiesIndexer doGetIndexEntitiesIndexer()
- Description copied from class:
AbstractParallelGpsDevice
- Returns an index entities indexer that knows how to index indexable entities.
- Specified by:
doGetIndexEntitiesIndexer in class AbstractParallelGpsDevice
setSessionFactory
public void setSessionFactory(SessionFactory sessionFactory)
- Sets the Hibernate
SessionFactory to be used before the start operation.
setFetchCount
public void setFetchCount(int fetchCount)
- Sets the fetch count for the indexing process. A large number will perform the indexing faster,
but will consume more memory. Defaults to
200.
getFetchCount
public int getFetchCount()
- Returns the fetch count for the indexing process. A large number will perform the indexing faster,
but will consume more memory. Default to
200.
isMirrorDataChanges
public boolean isMirrorDataChanges()
- Description copied from interface:
MirrorDataChangesGpsDevice
- Should the device perform real time data mirroring.
- Specified by:
isMirrorDataChanges in interface MirrorDataChangesGpsDevice
- Returns:
true if the device mirror data changes- See Also:
MirrorDataChangesGpsDevice.isMirrorDataChanges()
isIgnoreMirrorExceptions
public boolean isIgnoreMirrorExceptions()
- Should exceptions be ignored during the mirroring operations (the Hibernate event listeners).
Defaults to
false.
setIgnoreMirrorExceptions
public void setIgnoreMirrorExceptions(boolean ignoreMirrorExceptions)
- Should exceptions be ignored during the mirroring operations (the Hibernate event listeners).
Defaults to
false.
setMirrorDataChanges
public void setMirrorDataChanges(boolean mirrorDataChanges)
- Description copied from interface:
MirrorDataChangesGpsDevice
- Sets if the device will perform real time data changes mirroring.
- Specified by:
setMirrorDataChanges in interface MirrorDataChangesGpsDevice
- Parameters:
mirrorDataChanges - Should the device mirror data changes- See Also:
MirrorDataChangesGpsDevice.setMirrorDataChanges(boolean)
setEntitiesLocator
public void setEntitiesLocator(HibernateEntitiesLocator entitiesLocator)
- Sets a pluggable index entities locator allowing to control the indexes entties that
will be used. Defaults to
DefaultHibernateEntitiesLocator.
getMirrorFilter
public HibernateMirrorFilter getMirrorFilter()
- Returns mirroring filter that can filter hibernate mirror events. If no mirror filter is set
no filtering will happen.
setMirrorFilter
public void setMirrorFilter(HibernateMirrorFilter mirrorFilter)
- Sets a mirroring filter that can filter hibernate mirror events. If no mirror filter is set
no filtering will happen.
- Parameters:
mirrorFilter - The mirror filter handler
setNativeExtractor
public void setNativeExtractor(NativeHibernateExtractor nativeExtractor)
- Sets a native Hibernate extractor to work with frameworks that wrap the actual
SessionFactory.
setEntitiesIndexer
public void setEntitiesIndexer(HibernateIndexEntitiesIndexer entitiesIndexer)
- Sets a custom entities indexer allowing to control the indexing process.
Defaults to
PaginationHibernateIndexEntitiesIndexer.
setLifecycleInjector
public void setLifecycleInjector(HibernateEntityLifecycleInjector lifecycleInjector)
- Sets a custom lifecycle injector controlling the injection of Hibernate lifecycle
listeners for mirroring operations. Defaults to
DefaultHibernateEntityLifecycleInjector.
setIndexSelectQuery
public void setIndexSelectQuery(Class entityClass,
String selectQuery)
Sets a specific select statement for the index process of the given
entity class.
Note, when using ScrollableHibernateIndexEntitiesIndexer
it is preferable not to use this mehotd, instead use
setIndexQueryProvider(Class, HibernateQueryProvider) and return a
Hibernate Criteria object instead.
Note, this information is used when the device starts.
- Parameters:
entityClass - The Entity class to associate the select query withselectQuery - The select query to execute when indexing the given entity
setIndexSelectQuery
public void setIndexSelectQuery(String entityName,
String selectQuery)
- Sets a specific select statement for the index process of the given
entity name.
Note, when using ScrollableHibernateIndexEntitiesIndexer
it is preferable not to use this mehotd, instead use
setIndexQueryProvider(String, HibernateQueryProvider) and return a
Hibernate Criteria object instead.
Note, this information is used when the device starts.
- Parameters:
entityName - The entity name to associate the select query withselectQuery - The select query to execute when indexing the given entity
setIndexQueryProvider
public void setIndexQueryProvider(Class entityClass,
HibernateQueryProvider queryProvider)
- Sets a specific query provider for the index process of the given entity class.
Note, this information is used when the device starts.
- Parameters:
entityClass - The Entity class to associate the query provider withqueryProvider - The query provider to execute when indexing the given entity
setIndexQueryProvider
public void setIndexQueryProvider(String entityName,
HibernateQueryProvider queryProvider)
- Sets a specific query provider for the index process of the given entity name.
Note, this information is used when the device starts.
- Parameters:
entityName - The Entity name to associate the query provider withqueryProvider - The query provider to execute when indexing the given entity
setindexEntityInfo
public void setindexEntityInfo(HibernateEntityIndexInfo indexInfo)
- Allows to set
HibernateEntityIndexInfo which results
in calling setIndexQueryProvider(String, HibernateQueryProvider).
setindexEntityInfos
public void setindexEntityInfos(HibernateEntityIndexInfo[] indexInfos)
- Allows to set an array of
HibernateEntityIndexInfo which results
in calling setIndexQueryProvider(String, HibernateQueryProvider).
getSessionFactory
public SessionFactory getSessionFactory()
- Returns a native Hibernate extractor to work with frameworks that wrap the actual
SessionFactory.
Copyright (c) 2004-2008 The Compass Project.