1 package org.hibernate.event.def; 3 4 import java.io.Serializable ; 5 6 import org.hibernate.HibernateException; 7 import org.hibernate.collection.PersistentCollection; 8 import org.hibernate.event.EventSource; 9 import org.hibernate.persister.collection.CollectionPersister; 10 import org.hibernate.type.CollectionType; 11 12 22 public class OnUpdateVisitor extends ReattachVisitor { 23 24 OnUpdateVisitor(EventSource session, Serializable key) { 25 super(session, key); 26 } 27 28 Object processCollection(Object collection, CollectionType type) 29 throws HibernateException { 30 31 if (collection==CollectionType.UNFETCHED_COLLECTION) return null; 32 33 EventSource session = getSession(); 34 Serializable key = getKey(); 35 CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() ); 36 37 if ( collection!=null && (collection instanceof PersistentCollection) ) { 38 PersistentCollection wrapper = (PersistentCollection) collection; 39 40 if ( wrapper.setCurrentSession(session) ) { 41 43 if ( !isOwnerUnchanged(wrapper, persister, key) ) { 44 removeCollection(persister, key, session); 47 } 48 49 reattachCollection(wrapper, type); 50 } 51 else { 52 removeCollection(persister, key, session); 56 } 57 58 } 59 else { 60 removeCollection(persister, key, session); 64 } 66 67 return null; 68 69 } 70 71 } 72 | Popular Tags |