org.hibernate.engine
Class BatchFetchQueue

java.lang.Object
  extended by org.hibernate.engine.BatchFetchQueue

public class BatchFetchQueue
extends Object

Tracks entity and collection keys that are available for batch fetching, and the queries which were used to load entities, which can be re-used as a subquery for loading owned collections.

Author:
Gavin King

Field Summary
static Object MARKER
           
 
Constructor Summary
BatchFetchQueue(PersistenceContext context)
          Constructs a queue for the given context.
 
Method Summary
 void addBatchLoadableEntityKey(EntityKey key)
          If an EntityKey represents a batch loadable entity, add it to the queue.
 void addSubselect(EntityKey key, SubselectFetch subquery)
          Adds a subselect fetch decriptor for the given entity key.
 void clear()
          Clears all entries from this fetch queue.
 void clearSubselects()
          Clears all pending subselect fetches from the queue.
 Serializable[] getCollectionBatch(CollectionPersister collectionPersister, Serializable id, int batchSize, EntityMode entityMode)
          Get a batch of uninitialized collection keys for a given role
 Serializable[] getEntityBatch(EntityPersister persister, Serializable id, int batchSize, EntityMode entityMode)
          Get a batch of unloaded identifiers for this class, using a slightly complex algorithm that tries to grab keys registered immediately after the given key.
 SubselectFetch getSubselect(EntityKey key)
          Retrieve the fetch descriptor associated with the given entity key.
 void removeBatchLoadableEntityKey(EntityKey key)
          After evicting or deleting or loading an entity, we don't need to batch fetch it anymore, remove it from the queue if necessary
 void removeSubselect(EntityKey key)
          After evicting or deleting an entity, we don't need to know the query that was used to load it anymore (don't call this after loading the entity, since we might still need to load its collections)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MARKER

public static final Object MARKER
Constructor Detail

BatchFetchQueue

public BatchFetchQueue(PersistenceContext context)
Constructs a queue for the given context.

Parameters:
context - The owning context.
Method Detail

clear

public void clear()
Clears all entries from this fetch queue.


getSubselect

public SubselectFetch getSubselect(EntityKey key)
Retrieve the fetch descriptor associated with the given entity key.

Parameters:
key - The entity key for which to locate any defined subselect fetch.
Returns:
The fetch descriptor; may return null if no subselect fetch queued for this entity key.

addSubselect

public void addSubselect(EntityKey key,
                         SubselectFetch subquery)
Adds a subselect fetch decriptor for the given entity key.

Parameters:
key - The entity for which to register the subselect fetch.
subquery - The fetch descriptor.

removeSubselect

public void removeSubselect(EntityKey key)
After evicting or deleting an entity, we don't need to know the query that was used to load it anymore (don't call this after loading the entity, since we might still need to load its collections)


clearSubselects

public void clearSubselects()
Clears all pending subselect fetches from the queue.

Called after flushing.


addBatchLoadableEntityKey

public void addBatchLoadableEntityKey(EntityKey key)
If an EntityKey represents a batch loadable entity, add it to the queue.

Note that the contract here is such that any key passed in should previously have been been checked for existence within the PersistenceContext; failure to do so may cause the referenced entity to be included in a batch even though it is already associated with the PersistenceContext.


removeBatchLoadableEntityKey

public void removeBatchLoadableEntityKey(EntityKey key)
After evicting or deleting or loading an entity, we don't need to batch fetch it anymore, remove it from the queue if necessary


getCollectionBatch

public Serializable[] getCollectionBatch(CollectionPersister collectionPersister,
                                         Serializable id,
                                         int batchSize,
                                         EntityMode entityMode)
Get a batch of uninitialized collection keys for a given role

Parameters:
collectionPersister - The persister for the collection role.
id - A key that must be included in the batch fetch
batchSize - the maximum number of keys to return
Returns:
an array of collection keys, of length batchSize (padded with nulls)

getEntityBatch

public Serializable[] getEntityBatch(EntityPersister persister,
                                     Serializable id,
                                     int batchSize,
                                     EntityMode entityMode)
Get a batch of unloaded identifiers for this class, using a slightly complex algorithm that tries to grab keys registered immediately after the given key.

Parameters:
persister - The persister for the entities being loaded.
id - The identifier of the entity currently demanding load.
batchSize - The maximum number of keys to return
Returns:
an array of identifiers, of length batchSize (possibly padded with nulls)


Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.