Constructors Summary |
---|
public CollectionEntry(org.hibernate.persister.collection.CollectionPersister persister, org.hibernate.collection.PersistentCollection collection)For newly wrapped collections, or dereferenced collection wrappers
// new collections that get found + wrapped
// during flush shouldn't be ignored
ignore = false;
collection.clearDirty(); //a newly wrapped collection is NOT dirty (or we get unnecessary version updates)
snapshot = persister.isMutable() ?
collection.getSnapshot(persister) :
null;
collection.setSnapshot(loadedKey, role, snapshot);
|
public CollectionEntry(org.hibernate.collection.PersistentCollection collection, org.hibernate.persister.collection.CollectionPersister loadedPersister, Serializable loadedKey, boolean ignore)For collections just loaded from the database
this.ignore=ignore;
//collection.clearDirty()
this.loadedKey = loadedKey;
setLoadedPersister(loadedPersister);
collection.setSnapshot(loadedKey, role, null);
//postInitialize() will be called after initialization
|
public CollectionEntry(org.hibernate.persister.collection.CollectionPersister loadedPersister, Serializable loadedKey)For uninitialized detached collections
// detached collection wrappers that get found + reattached
// during flush shouldn't be ignored
ignore = false;
//collection.clearDirty()
this.loadedKey = loadedKey;
setLoadedPersister(loadedPersister);
|
CollectionEntry(org.hibernate.collection.PersistentCollection collection, SessionFactoryImplementor factory)For initialized detached collections
// detached collections that get found + reattached
// during flush shouldn't be ignored
ignore = false;
loadedKey = collection.getKey();
setLoadedPersister( factory.getCollectionPersister( collection.getRole() ) );
snapshot = collection.getStoredSnapshot();
|
private CollectionEntry(String role, Serializable snapshot, Serializable loadedKey, SessionFactoryImplementor factory)Used from custom serialization.
this.role = role;
this.snapshot = snapshot;
this.loadedKey = loadedKey;
if ( role != null ) {
afterDeserialize( factory );
}
|
Methods Summary |
---|
public void | afterAction(org.hibernate.collection.PersistentCollection collection)Called after execution of an action
loadedKey = getCurrentKey();
setLoadedPersister( getCurrentPersister() );
boolean resnapshot = collection.wasInitialized() &&
( isDoremove() || isDorecreate() || isDoupdate() );
if ( resnapshot ) {
snapshot = loadedPersister==null || !loadedPersister.isMutable() ?
null :
collection.getSnapshot(loadedPersister); //re-snapshot
}
collection.postAction();
|
void | afterDeserialize(SessionFactoryImplementor factory)
loadedPersister = factory.getCollectionPersister(role);
|
static org.hibernate.engine.CollectionEntry | deserialize(java.io.ObjectInputStream ois, SessionImplementor session)Custom deserialization routine used during deserialization of a
Session/PersistenceContext for increased performance.
return new CollectionEntry(
( String ) ois.readObject(),
( Serializable ) ois.readObject(),
( Serializable ) ois.readObject(),
session.getFactory()
);
|
private void | dirty(org.hibernate.collection.PersistentCollection collection)Determine if the collection is "really" dirty, by checking dirtiness
of the collection elements, if necessary
boolean forceDirty = collection.wasInitialized() &&
!collection.isDirty() && //optimization
getLoadedPersister() != null &&
getLoadedPersister().isMutable() && //optimization
( collection.isDirectlyAccessible() || getLoadedPersister().getElementType().isMutable() ) && //optimization
!collection.equalsSnapshot( getLoadedPersister() );
if ( forceDirty ) {
collection.dirty();
}
|
public java.io.Serializable | getCurrentKey()This is only available late during the flush
cycle
return currentKey;
|
public org.hibernate.persister.collection.CollectionPersister | getCurrentPersister()
return currentPersister;
|
public java.io.Serializable | getKey()
return getLoadedKey();
|
public java.io.Serializable | getLoadedKey()
return loadedKey;
|
public org.hibernate.persister.collection.CollectionPersister | getLoadedPersister()This is only available late during the flush cycle
return loadedPersister;
|
public java.util.Collection | getOrphans(java.lang.String entityName, org.hibernate.collection.PersistentCollection collection)Get the collection orphans (entities which were removed from the collection)
if (snapshot==null) {
throw new AssertionFailure("no collection snapshot for orphan delete");
}
return collection.getOrphans( snapshot, entityName );
|
public java.lang.String | getRole()
return role;
|
public java.io.Serializable | getSnapshot()
return snapshot;
|
public boolean | isDorecreate()
return dorecreate;
|
public boolean | isDoremove()
return doremove;
|
public boolean | isDoupdate()
return doupdate;
|
public boolean | isIgnore()
return ignore;
|
public boolean | isProcessed()
return processed;
|
public boolean | isReached()
return reached;
|
public boolean | isSnapshotEmpty(org.hibernate.collection.PersistentCollection collection)
//TODO: does this really need to be here?
// does the collection already have
// it's own up-to-date snapshot?
return collection.wasInitialized() &&
( getLoadedPersister()==null || getLoadedPersister().isMutable() ) &&
collection.isSnapshotEmpty( getSnapshot() );
|
public void | postFlush(org.hibernate.collection.PersistentCollection collection)Called after a successful flush
if ( isIgnore() ) {
ignore = false;
}
else if ( !isProcessed() ) {
throw new AssertionFailure( "collection [" + collection.getRole() + "] was not processed by flush()" );
}
collection.setSnapshot(loadedKey, role, snapshot);
|
public void | postInitialize(org.hibernate.collection.PersistentCollection collection)
snapshot = getLoadedPersister().isMutable() ?
collection.getSnapshot( getLoadedPersister() ) :
null;
collection.setSnapshot(loadedKey, role, snapshot);
|
public void | preFlush(org.hibernate.collection.PersistentCollection collection)
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.debug(
"Collection dirty: " +
MessageHelper.collectionInfoString( getLoadedPersister().getRole(), getLoadedKey() )
);
}
setDoupdate(false);
setDoremove(false);
setDorecreate(false);
setReached(false);
setProcessed(false);
|
void | serialize(java.io.ObjectOutputStream oos)Custom serialization routine used during serialization of a
Session/PersistenceContext for increased performance.
oos.writeObject( role );
oos.writeObject( snapshot );
oos.writeObject( loadedKey );
|
public void | setCurrentKey(java.io.Serializable currentKey)
this.currentKey = currentKey;
|
public void | setCurrentPersister(org.hibernate.persister.collection.CollectionPersister currentPersister)
this.currentPersister = currentPersister;
|
public void | setDorecreate(boolean dorecreate)
this.dorecreate = dorecreate;
|
public void | setDoremove(boolean doremove)
this.doremove = doremove;
|
public void | setDoupdate(boolean doupdate)
this.doupdate = doupdate;
|
private void | setLoadedPersister(org.hibernate.persister.collection.CollectionPersister persister)
loadedPersister = persister;
setRole( persister == null ? null : persister.getRole() );
|
public void | setProcessed(boolean processed)
this.processed = processed;
|
public void | setReached(boolean reached)
this.reached = reached;
|
public void | setRole(java.lang.String role)
this.role = role;
|
public java.lang.String | toString()
String result = "CollectionEntry" +
MessageHelper.collectionInfoString( loadedPersister.getRole(), loadedKey );
if (currentPersister!=null) {
result += "->" +
MessageHelper.collectionInfoString( currentPersister.getRole(), currentKey );
}
return result;
|
public boolean | wasDereferenced()
return getLoadedKey() == null;
|