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.engine.SessionImplementor; 9 import org.hibernate.event.EventSource; 10 import org.hibernate.persister.collection.CollectionPersister; 11 import org.hibernate.type.CollectionType; 12 13 22 public class OnLockVisitor extends ReattachVisitor { 23 24 public OnLockVisitor(EventSource session, Serializable key) { 25 super(session, key); 26 } 27 28 Object processCollection(Object collection, CollectionType type) 29 throws HibernateException { 30 31 SessionImplementor session = getSession(); 32 CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() ); 33 34 if (collection==null) { 35 } 37 else if ( collection instanceof PersistentCollection ) { 38 PersistentCollection persistentCollection = (PersistentCollection) collection; 39 40 if ( persistentCollection.setCurrentSession(session) ) { 41 42 if ( isOwnerUnchanged( persistentCollection, persister, getKey() ) ) { 43 if ( persistentCollection.isDirty() ) { 45 throw new HibernateException("reassociated object has dirty collection"); 46 } 47 reattachCollection(persistentCollection, type); 48 } 49 else { 50 throw new HibernateException("reassociated object has dirty collection reference"); 52 } 53 54 } 55 else { 56 throw new HibernateException("reassociated object has dirty collection reference"); 60 } 61 62 } 63 else { 64 throw new HibernateException("reassociated object has dirty collection reference (or an array)"); 67 } 68 69 return null; 70 71 } 72 73 } 74 | Popular Tags |