Methods Summary |
---|
public void | cleanup(java.sql.ResultSet resultSet)Release internal state associated with the given result set.
This should be called when we are done with processing said result set,
ideally as the result set is being closed.
if ( collectionLoadContexts != null ) {
CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) collectionLoadContexts.remove( resultSet );
collectionLoadContext.cleanup();
}
if ( entityLoadContexts != null ) {
EntityLoadContext entityLoadContext = ( EntityLoadContext ) entityLoadContexts.remove( resultSet );
entityLoadContext.cleanup();
}
|
public void | cleanup()Release internal state associated with *all* result sets.
This is intended as a "failsafe" process to make sure we get everything
cleaned up and released.
if ( collectionLoadContexts != null ) {
Iterator itr = collectionLoadContexts.values().iterator();
while ( itr.hasNext() ) {
CollectionLoadContext collectionLoadContext = ( CollectionLoadContext ) itr.next();
log.warn( "fail-safe cleanup (collections) : " + collectionLoadContext );
collectionLoadContext.cleanup();
}
collectionLoadContexts.clear();
}
if ( entityLoadContexts != null ) {
Iterator itr = entityLoadContexts.values().iterator();
while ( itr.hasNext() ) {
EntityLoadContext entityLoadContext = ( EntityLoadContext ) itr.next();
log.warn( "fail-safe cleanup (entities) : " + entityLoadContext );
entityLoadContext.cleanup();
}
entityLoadContexts.clear();
}
|
void | cleanupCollectionXRefs(java.util.Set entryKeys)
Iterator itr = entryKeys.iterator();
while ( itr.hasNext() ) {
final CollectionKey entryKey = ( CollectionKey ) itr.next();
xrefLoadingCollectionEntries.remove( entryKey );
}
|
public CollectionLoadContext | getCollectionLoadContext(java.sql.ResultSet resultSet)Get the {@link CollectionLoadContext} associated with the given
{@link ResultSet}, creating one if needed.
CollectionLoadContext context = null;
if ( collectionLoadContexts == null ) {
collectionLoadContexts = IdentityMap.instantiate( 8 );
}
else {
context = ( CollectionLoadContext ) collectionLoadContexts.get( resultSet );
}
if ( context == null ) {
if ( log.isTraceEnabled() ) {
log.trace( "constructing collection load context for result set [" + resultSet + "]" );
}
context = new CollectionLoadContext( this, resultSet );
collectionLoadContexts.put( resultSet, context );
}
return context;
|
public EntityLoadContext | getEntityLoadContext(java.sql.ResultSet resultSet)
EntityLoadContext context = null;
if ( entityLoadContexts == null ) {
entityLoadContexts = IdentityMap.instantiate( 8 );
}
else {
context = ( EntityLoadContext ) entityLoadContexts.get( resultSet );
}
if ( context == null ) {
context = new EntityLoadContext( this, resultSet );
entityLoadContexts.put( resultSet, context );
}
return context;
|
private org.hibernate.EntityMode | getEntityMode()
return getSession().getEntityMode();
|
java.util.Map | getLoadingCollectionXRefs()
return xrefLoadingCollectionEntries;
|
public org.hibernate.engine.PersistenceContext | getPersistenceContext()Retrieves the persistence context to which this is bound.
return persistenceContext;
|
private org.hibernate.engine.SessionImplementor | getSession()
return getPersistenceContext().getSession();
|
public boolean | hasLoadingCollectionEntries()Do we currently have any internal entries corresponding to loading
collections?
return ( xrefLoadingCollectionEntries != null && !xrefLoadingCollectionEntries.isEmpty() );
|
public org.hibernate.collection.PersistentCollection | locateLoadingCollection(org.hibernate.persister.collection.CollectionPersister persister, java.io.Serializable ownerKey)Attempt to locate the loading collection given the owner's key. The lookup here
occurs against all result-set contexts...
LoadingCollectionEntry lce = locateLoadingCollectionEntry( new CollectionKey( persister, ownerKey, getEntityMode() ) );
if ( lce != null ) {
if ( log.isTraceEnabled() ) {
log.trace( "returning loading collection:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
}
return lce.getCollection();
}
else {
// todo : should really move this log statement to CollectionType, where this is used from...
if ( log.isTraceEnabled() ) {
log.trace( "creating collection wrapper:" + MessageHelper.collectionInfoString( persister, ownerKey, getSession().getFactory() ) );
}
return null;
}
|
LoadingCollectionEntry | locateLoadingCollectionEntry(org.hibernate.engine.CollectionKey key)Locate the LoadingCollectionEntry within *any* of the tracked
{@link CollectionLoadContext}s.
Implementation note: package protected, as this is meant solely for use
by {@link CollectionLoadContext} to be able to locate collections
being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
if ( xrefLoadingCollectionEntries == null ) {
return null;
}
if ( log.isTraceEnabled() ) {
log.trace( "attempting to locate loading collection entry [" + key + "] in any result-set context" );
}
LoadingCollectionEntry rtn = ( LoadingCollectionEntry ) xrefLoadingCollectionEntries.get( key );
if ( log.isTraceEnabled() ) {
if ( rtn == null ) {
log.trace( "collection [" + key + "] located in load context" );
}
else {
log.trace( "collection [" + key + "] not located in load context" );
}
}
return rtn;
|
void | registerLoadingCollectionXRef(org.hibernate.engine.CollectionKey entryKey, LoadingCollectionEntry entry)Register a loading collection xref.
This xref map is used because sometimes a collection is in process of
being loaded from one result set, but needs to be accessed from the
context of another "nested" result set processing.
Implementation note: package protected, as this is meant solely for use
by {@link CollectionLoadContext} to be able to locate collections
being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
if ( xrefLoadingCollectionEntries == null ) {
xrefLoadingCollectionEntries = new HashMap();
}
xrefLoadingCollectionEntries.put( entryKey, entry );
|
void | unregisterLoadingCollectionXRef(org.hibernate.engine.CollectionKey key)The inverse of {@link #registerLoadingCollectionXRef}. Here, we are done
processing the said collection entry, so we remove it from the
load context.
The idea here is that other loading collections can now reference said
collection directly from the {@link PersistenceContext} because it
has completed its load cycle.
Implementation note: package protected, as this is meant solely for use
by {@link CollectionLoadContext} to be able to locate collections
being loaded by other {@link CollectionLoadContext}s/{@link ResultSet}s.
if ( !hasLoadingCollectionEntries() ) {
return;
}
xrefLoadingCollectionEntries.remove(key);
|