Java Code Examples for org.hibernate.collection.PersistentCollection#setSnapshot()

The following examples show how to use org.hibernate.collection.PersistentCollection#setSnapshot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CollectionEntry.java    From cacheonix-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * For collections just loaded from the database
 */
public CollectionEntry(
		final PersistentCollection collection, 
		final CollectionPersister loadedPersister, 
		final Serializable loadedKey, 
		final boolean ignore
) {
	this.ignore=ignore;

	//collection.clearDirty()
	
	this.loadedKey = loadedKey;
	setLoadedPersister(loadedPersister);

	collection.setSnapshot(loadedKey, role, null);

	//postInitialize() will be called after initialization
}
 
Example 2
Source File: CollectionEntry.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * For newly wrapped collections, or dereferenced collection wrappers
 */
public CollectionEntry(CollectionPersister persister, PersistentCollection collection) {
	// 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);
}
 
Example 3
Source File: CollectionEntry.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Called after a successful flush
 */
public void postFlush(PersistentCollection collection) throws HibernateException {
	if ( isIgnore() ) {
		ignore = false;
	}
	else if ( !isProcessed() ) {
		throw new AssertionFailure( "collection [" + collection.getRole() + "] was not processed by flush()" );
	}
	collection.setSnapshot(loadedKey, role, snapshot);
}
 
Example 4
Source File: CollectionEntry.java    From cacheonix-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void postInitialize(PersistentCollection collection) throws HibernateException {
	snapshot = getLoadedPersister().isMutable() ?
			collection.getSnapshot( getLoadedPersister() ) :
			null;
	collection.setSnapshot(loadedKey, role, snapshot);
}