Class AbstractBatchFinder

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

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 Details

    • AbstractBatchFinder

      public AbstractBatchFinder()
  • Method Details

    • 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)