FileDocCategorySizeDatePackage
CollectionUpdateAction.javaAPI DocHibernate 3.2.52415Sun Jul 24 16:26:22 BST 2005org.hibernate.action

CollectionUpdateAction

public final class CollectionUpdateAction extends CollectionAction

Fields Summary
private final boolean
emptySnapshot
Constructors Summary
public CollectionUpdateAction(org.hibernate.collection.PersistentCollection collection, org.hibernate.persister.collection.CollectionPersister persister, Serializable id, boolean emptySnapshot, org.hibernate.engine.SessionImplementor session)

		super( persister, collection, id, session );
		this.emptySnapshot = emptySnapshot;
	
Methods Summary
public voidexecute()

		final Serializable id = getKey();
		final SessionImplementor session = getSession();
		final CollectionPersister persister = getPersister();
		final PersistentCollection collection = getCollection();
		boolean affectedByFilters = persister.isAffectedByEnabledFilters(session);

		if ( !collection.wasInitialized() ) {
			if ( !collection.hasQueuedOperations() ) throw new AssertionFailure( "no queued adds" );
			//do nothing - we only need to notify the cache...
		}
		else if ( !affectedByFilters && collection.empty() ) {
			if ( !emptySnapshot ) persister.remove( id, session );
		}
		else if ( collection.needsRecreate(persister) ) {
			if (affectedByFilters) {
				throw new HibernateException(
					"cannot recreate collection while filter is enabled: " + 
					MessageHelper.collectionInfoString( persister, id, persister.getFactory() )
				);
			}
			if ( !emptySnapshot ) persister.remove( id, session );
			persister.recreate( collection, id, session );
		}
		else {
			persister.deleteRows( collection, id, session );
			persister.updateRows( collection, id, session );
			persister.insertRows( collection, id, session );
		}

		getSession().getPersistenceContext()
			.getCollectionEntry(collection)
			.afterAction(collection);

		evict();

		if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
			getSession().getFactory().getStatisticsImplementor().
					updateCollection( getPersister().getRole() );
		}