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

The following examples show how to use org.hibernate.collection.spi.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 lams with GNU General Public License v2.0 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 lams with GNU General Public License v2.0 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 lams with GNU General Public License v2.0 5 votes vote down vote up
public void postInitialize(PersistentCollection collection) throws HibernateException {
	snapshot = getLoadedPersister().isMutable()
			? collection.getSnapshot( getLoadedPersister() )
			: null;
	collection.setSnapshot(loadedKey, role, snapshot);
	if ( getLoadedPersister().getBatchSize() > 1 ) {
		( (AbstractPersistentCollection) collection ).getSession()
				.getPersistenceContext()
				.getBatchFetchQueue()
				.removeBatchLoadableCollection( this );
	}
}
 
Example 4
Source File: CollectionEntry.java    From lams with GNU General Public License v2.0 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 HibernateException( LOG.collectionNotProcessedByFlush( collection.getRole() ) );
	}
	collection.setSnapshot(loadedKey, role, snapshot);
}
 
Example 5
Source File: CollectionEntry.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Reset the stored snapshot for both the persistent collection and this collection entry. 
 * Used during the merge of detached collections.
 * 
 * @param collection the persistentcollection to be updated
 * @param storedSnapshot the new stored snapshot
 */
public void resetStoredSnapshot(PersistentCollection collection, Serializable storedSnapshot) {
	LOG.debugf("Reset storedSnapshot to %s for %s", storedSnapshot, this);

	if ( fromMerge ) {
		return; // EARLY EXIT!
	}

	snapshot = storedSnapshot;
	collection.setSnapshot( loadedKey, role, snapshot );
	fromMerge = true;
}