KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > action > CollectionRemoveAction


1 //$Id: CollectionRemoveAction.java,v 1.8 2005/06/15 13:20:12 oneovthafew Exp $
2
package org.hibernate.action;
3
4 import org.hibernate.HibernateException;
5 import org.hibernate.cache.CacheException;
6 import org.hibernate.collection.PersistentCollection;
7 import org.hibernate.engine.SessionImplementor;
8 import org.hibernate.persister.collection.CollectionPersister;
9
10 import java.io.Serializable JavaDoc;
11
12 public final class CollectionRemoveAction extends CollectionAction {
13
14     private boolean emptySnapshot;
15
16     public CollectionRemoveAction(
17                 final PersistentCollection collection,
18                 final CollectionPersister persister,
19                 final Serializable JavaDoc id,
20                 final boolean emptySnapshot,
21                 final SessionImplementor session)
22             throws CacheException {
23         super( persister, collection, id, session );
24         this.emptySnapshot = emptySnapshot;
25     }
26
27     public void execute() throws HibernateException {
28         if ( !emptySnapshot ) getPersister().remove( getKey(), getSession() );
29         
30         final PersistentCollection collection = getCollection();
31         if (collection!=null) {
32             getSession().getPersistenceContext()
33                 .getCollectionEntry(collection)
34                 .afterAction(collection);
35         }
36         
37         evict();
38
39         if ( getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
40             getSession().getFactory().getStatisticsImplementor()
41                     .removeCollection( getPersister().getRole() );
42         }
43     }
44
45
46 }
47
48
49
50
51
52
53
54
Popular Tags