com.atlassian.crowd.util.persistence.hibernate.batch
Class AbstractBatchFinder

java.lang.Object
  extended by com.atlassian.crowd.util.persistence.hibernate.batch.AbstractBatchFinder
All Implemented Interfaces:
BatchFinder
Direct Known Subclasses:
Hibernate4BatchFinder

public abstract class AbstractBatchFinder
extends Object
implements BatchFinder

Abstract implementation of the batch finder, sub classes should extend this implementation with an implementation of processBatchFind(long, java.util.Collection, Class) which performs the hibernate version specific search.

Callback methods beforeFind() and afterFind() can be used to wrap the search in a session and/or transaction.


Constructor Summary
AbstractBatchFinder()
           
 
Method Summary
protected  void afterFind()
           
protected  void beforeFind()
           
<E extends Serializable>
Collection<E>
find(long directoryID, Collection<String> names, Class<E> persistentClass)
          Returns a collection of entities that match the names provided.
protected abstract
<E> Collection<E>
processBatchFind(long directoryID, Collection<String> names, Class<E> persistentClass)
           
 void setBatchSize(int batchSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractBatchFinder

public AbstractBatchFinder()
Method Detail

setBatchSize

public void setBatchSize(int batchSize)

find

public <E extends Serializable> Collection<E> find(long directoryID,
                                                   Collection<String> names,
                                                   Class<E> persistentClass)
Returns a collection of entities that match the names provided. Any names that cannot be matched to persistent entities are not present in the resultant collection.

Internally, this performs a: SELECT * FROM entityTable WHERE entityName IN (...)

This is batched such that the size of the IN clause is at most the batchSize.

Specified by:
find in interface BatchFinder
Parameters:
directoryID - directory ID of the entities to return.
names - collection of entity names. This, along with the directoryID should form the primary key of the entity.
persistentClass - the persistent class to lookup. This must be a Hibernate-mapped DirectoryEntity.
Returns:
a collection of the DirectoryEntities that exist matching any of the supplied names.

beforeFind

protected void beforeFind()

afterFind

protected void afterFind()

processBatchFind

protected abstract <E> Collection<E> processBatchFind(long directoryID,
                                                      Collection<String> names,
                                                      Class<E> persistentClass)


Copyright © 2013 Atlassian. All Rights Reserved.