KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > event > def > FlushVisitor


1 //$Id: FlushVisitor.java,v 1.8 2005/05/27 03:53:59 oneovthafew Exp $
2
package org.hibernate.event.def;
3
4 import org.hibernate.HibernateException;
5 import org.hibernate.collection.PersistentCollection;
6 import org.hibernate.engine.Collections;
7 import org.hibernate.event.EventSource;
8 import org.hibernate.type.CollectionType;
9
10 /**
11  * Process collections reachable from an entity. This
12  * visitor assumes that wrap was already performed for
13  * the entity.
14  *
15  * @author Gavin King
16  */

17 public class FlushVisitor extends AbstractVisitor {
18     
19     private Object JavaDoc owner;
20
21     Object JavaDoc processCollection(Object JavaDoc collection, CollectionType type)
22     throws HibernateException {
23         
24         if (collection==CollectionType.UNFETCHED_COLLECTION) {
25             return null;
26         }
27
28         if (collection!=null) {
29             final PersistentCollection coll;
30             if ( type.hasHolder( getSession().getEntityMode() ) ) {
31                 coll = getSession().getPersistenceContext().getCollectionHolder(collection);
32             }
33             else {
34                 coll = (PersistentCollection) collection;
35             }
36
37             Collections.processReachableCollection( coll, type, owner, getSession() );
38         }
39
40         return null;
41
42     }
43
44     FlushVisitor(EventSource session, Object JavaDoc owner) {
45         super(session);
46         this.owner = owner;
47     }
48
49 }
50
Popular Tags