org.compass.gps.device.jpa.indexer
Class HibernateJpaIndexEntitiesIndexer

java.lang.Object
  extended by org.compass.gps.device.jpa.indexer.HibernateJpaIndexEntitiesIndexer
All Implemented Interfaces:
JpaIndexEntitiesIndexer, IndexEntitiesIndexer

public class HibernateJpaIndexEntitiesIndexer
extends Object
implements JpaIndexEntitiesIndexer

A Hibernate indexer uses Hibernate ScrollableResults to index the database instead of using setFirstResult and setMaxResults. Using scrollable results yields better performance especially for large result set.

Also takes into accont if using HibernateJpaQueryProvider by called its createCriteria instead of the default createQuery. The criteria better handles outer joins, allows to set the fetch size, and automatically supports ordering by the ids of the entities.

Note, if using JpaGpsDevice.setIndexSelectQuery(Class, String) will cause not to be able to use Criteria. Instead, make sure to use JpaGpsDevice.setIndexQueryProvider(Class, org.compass.gps.device.jpa.queryprovider.JpaQueryProvider) and provider your own extension on top of HibernateJpaQueryProvider that returns your own Criteria.

Author:
kimchy

Constructor Summary
HibernateJpaIndexEntitiesIndexer()
           
 
Method Summary
 void performIndex(CompassSession session, IndexEntity[] entities)
          Performs the actual indexing of the list of index entities.
 void setJpaGpsDevice(JpaGpsDevice jpaGpsDevice)
          Sets the jpa gps device for the given indexer.
 void setPerformOrderById(boolean performOrderById)
          Should this indxer order by the ids when Criteria is available.
 void setPerformOrderById(String entity, boolean performOrderById)
          Should this indxer order by the ids when Criteria is available for the given entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HibernateJpaIndexEntitiesIndexer

public HibernateJpaIndexEntitiesIndexer()
Method Detail

setJpaGpsDevice

public void setJpaGpsDevice(JpaGpsDevice jpaGpsDevice)
Description copied from interface: JpaIndexEntitiesIndexer
Sets the jpa gps device for the given indexer. Called once when the device starts up.

Specified by:
setJpaGpsDevice in interface JpaIndexEntitiesIndexer

setPerformOrderById

public void setPerformOrderById(boolean performOrderById)
Should this indxer order by the ids when Criteria is available. Defaults to true.


setPerformOrderById

public void setPerformOrderById(String entity,
                                boolean performOrderById)
Should this indxer order by the ids when Criteria is available for the given entity. Defaults to setPerformOrderById(boolean).


performIndex

public void performIndex(CompassSession session,
                         IndexEntity[] entities)
Description copied from interface: IndexEntitiesIndexer
Performs the actual indexing of the list of index entities. Usually, an index entity represent a group of indexable content (like a certain class when using ORM, or a select statement). This method perform the fetching of the data and indexing it in Compass using the provided Compass session.

Specified by:
performIndex in interface IndexEntitiesIndexer
Parameters:
session - The compass session to index the data with
entities - A list of entities to perform the indexing by


Copyright (c) 2004-2008 The Compass Project.