【Java开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了Java开源代码-CollectionRemoveAction.java的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
//$Id: CollectionRemoveAction.java 7147 2005-06-15 13:20:13Z oneovthafew $
package org.hibernate.action;
import org.hibernate.HibernateException;
import org.hibernate.cache.CacheException;
import org.hibernate.collection.PersistentCollection;
import org.hibernate.engine.SessionImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import java.io.Serializable;
public final class CollectionRemoveAction extends CollectionAction {
private boolean emptySnapshot;
public CollectionRemoveAction(
final PersistentCollection collection,
final CollectionPersister persister,
final Serializable id,
final boolean emptySnapshot,
final SessionImplementor session)
throws CacheException {
super( persister, collection, id, session );
this.emptySnapshot = emptySnapshot;
}
public void execute() throws HibernateException {
if ( !emptySnapshot ) getPersister().remove( getKey(), getSession() );
final PersistentCollection collection = getCollection();
if (collection!=null) {
getSession().getPersistenceContext()
.getCollectionEntry(collection)
.afterAction(collection);
}
evict();
if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
getSession().getFactory().getStatisticsImplementor()
.removeCollection( getPersister().getRole() );
}
}
}