public boolean wasDereferenced() { return getLoadedKey() == null; }
public Serializable getKey() { return getLoadedKey(); }
/** * Get the ID for the entity that owned this persistent collection when it was loaded * * @param ce The collection entry * @return the owner ID if available from the collection's loaded key; otherwise, returns null */ private Serializable getLoadedCollectionOwnerIdOrNull(CollectionEntry ce) { if ( ce == null || ce.getLoadedKey() == null || ce.getLoadedPersister() == null ) { return null; } // TODO: an alternative is to check if the owner has changed; if it hasn't then // get the ID from collection.getOwner() return ce.getLoadedPersister().getCollectionType().getIdOfOwnerOrNull( ce.getLoadedKey(), session ); }
final PersistentCollection collection = me.getValue(); if ( ce.getLoadedKey() == null ) { ce.getLoadedKey(), collectionPersister.getFactory() ); else if ( !isCached( ce.getLoadedKey(), collectionPersister ) ) { keys[i++] = ce.getLoadedKey();
ce.getLoadedPersister(), this, ce.getLoadedKey(), session
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); final CollectionEntry entry = persistenceContext.getCollectionEntry( coll ); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Found collection with unloaded owner: %s", MessageHelper.collectionInfoString( entry.getLoadedPersister(), coll, entry.getLoadedKey(), session ) ); } entry.setCurrentPersister( entry.getLoadedPersister() ); entry.setCurrentKey( entry.getLoadedKey() ); prepareCollectionForUpdate( coll, entry, session.getFactory() ); }
private void evictCollection(PersistentCollection collection) { CollectionEntry ce = (CollectionEntry) getSession().getPersistenceContext().getCollectionEntries().remove(collection); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Evicting collection: %s", MessageHelper.collectionInfoString( ce.getLoadedPersister(), collection, ce.getLoadedKey(), getSession() ) ); } if (ce.getLoadedPersister() != null && ce.getLoadedPersister().getBatchSize() > 1) { getSession().getPersistenceContext().getBatchFetchQueue().removeBatchLoadableCollection(ce); } if ( ce.getLoadedPersister() != null && ce.getLoadedKey() != null ) { //TODO: is this 100% correct? getSession().getPersistenceContext().getCollectionsByKey().remove( new CollectionKey( ce.getLoadedPersister(), ce.getLoadedKey() ) ); } }
collectionEntry.getLoadedKey() ); persistenceContext.getCollectionsByKey().put(collectionKey, persistentCollection);
@Override public Boolean doWork() { final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this ); final CollectionPersister persister = entry.getLoadedPersister(); if ( persister.isExtraLazy() ) { if ( hasQueuedOperations() ) { session.flush(); } return persister.indexExists( entry.getLoadedKey(), index, session ); } else { read(); } return null; } }
@Override public Boolean doWork() { final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this ); final CollectionPersister persister = entry.getLoadedPersister(); if ( persister.isExtraLazy() ) { if ( hasQueuedOperations() ) { session.flush(); } return persister.elementExists( entry.getLoadedKey(), element, session ); } else { read(); } return null; } }
@Override public Boolean doWork() { final CollectionEntry entry = session.getPersistenceContext().getCollectionEntry( AbstractPersistentCollection.this ); if ( entry != null ) { final CollectionPersister persister = entry.getLoadedPersister(); if ( persister.isExtraLazy() ) { if ( hasQueuedOperations() ) { session.flush(); } cachedSize = persister.getSize( entry.getLoadedKey(), session ); return true; } else { read(); } } else{ throwLazyInitializationExceptionIfNotConnected(); } return false; } }
session.getInterceptor().onCollectionRemove( coll, ce.getLoadedKey() ); actionQueue.addAction( new CollectionRemoveAction( coll, ce.getLoadedPersister(), ce.getLoadedKey(), ce.isSnapshotEmpty(coll), session session.getInterceptor().onCollectionUpdate( coll, ce.getLoadedKey() ); actionQueue.addAction( new CollectionUpdateAction( coll, ce.getLoadedPersister(), ce.getLoadedKey(), ce.isSnapshotEmpty(coll), session coll, ce.getLoadedPersister(), ce.getLoadedKey(), session
ce.getLoadedPersister(), collection, ce.getLoadedKey(), source ce.getLoadedKey(), ce.getLoadedPersister(), collection, LOG.trace( "Collection not cached" ); ce.getLoadedPersister().initialize( ce.getLoadedKey(), source ); if ( traceEnabled ) { LOG.trace( "Collection initialized" );
public void preFlush(PersistentCollection collection) throws HibernateException { if ( loadedKey == null && collection.getKey() != null ) { loadedKey = collection.getKey(); } boolean nonMutableChange = collection.isDirty() && getLoadedPersister() != null && !getLoadedPersister().isMutable(); if ( nonMutableChange ) { throw new HibernateException( "changed an immutable collection instance: " + MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() ) ); } dirty( collection ); if ( LOG.isDebugEnabled() && collection.isDirty() && getLoadedPersister() != null ) { LOG.debugf( "Collection dirty: %s", MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() ) ); } setReached( false ); setProcessed( false ); setDoupdate( false ); setDoremove( false ); setDorecreate( false ); }
&& !currentPersister.getKeyType().isEqual( entry.getLoadedKey(), entry.getCurrentKey(), factory ) && !( entry.getLoadedKey() instanceof DelayedPostInsertIdentifier );
new TypedValue( entry.getLoadedPersister().getKeyType(), entry.getLoadedKey()
ce.getLoadedPersister(), collection, ce.getLoadedKey(), session ce.getLoadedPersister(), collection, ce.getLoadedKey(), session
"Collection dereferenced: %s", MessageHelper.collectionInfoString( loadedPersister, coll, entry.getLoadedKey(), session
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); CollectionEntry entry = persistenceContext.getCollectionEntry(coll); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Found collection with unloaded owner: %s", MessageHelper.collectionInfoString( entry.getLoadedPersister(), entry.getLoadedKey(), session.getFactory() ) ); } entry.setCurrentPersister( entry.getLoadedPersister() ); entry.setCurrentKey( entry.getLoadedKey() ); prepareCollectionForUpdate( coll, entry, session.getFactory() ); }
private static void processNeverReferencedCollection(PersistentCollection coll, SessionImplementor session) throws HibernateException { final PersistenceContext persistenceContext = session.getPersistenceContext(); CollectionEntry entry = persistenceContext.getCollectionEntry(coll); if ( LOG.isDebugEnabled() ) { LOG.debugf( "Found collection with unloaded owner: %s", MessageHelper.collectionInfoString( entry.getLoadedPersister(), entry.getLoadedKey(), session.getFactory() ) ); } entry.setCurrentPersister( entry.getLoadedPersister() ); entry.setCurrentKey( entry.getLoadedKey() ); prepareCollectionForUpdate( coll, entry, session.getFactory() ); }