1 package org.hibernate.event.def; 3 4 import org.hibernate.HibernateException; 5 import org.hibernate.collection.PersistentCollection; 6 import org.hibernate.engine.SessionImplementor; 7 import org.hibernate.event.EventSource; 8 import org.hibernate.type.CollectionType; 9 10 18 public class DirtyCollectionSearchVisitor extends AbstractVisitor { 19 20 private boolean dirty = false; 21 private boolean[] propertyVersionability; 22 23 DirtyCollectionSearchVisitor(EventSource session, boolean[] propertyVersionability) { 24 super(session); 25 this.propertyVersionability = propertyVersionability; 26 } 27 28 boolean wasDirtyCollectionFound() { 29 return dirty; 30 } 31 32 Object processCollection(Object collection, CollectionType type) 33 throws HibernateException { 34 35 if (collection!=null) { 36 37 SessionImplementor session = getSession(); 38 39 final PersistentCollection persistentCollection; 40 if ( type.isArrayType() ) { 41 persistentCollection = session.getPersistenceContext().getCollectionHolder(collection); 42 } 46 else { 47 persistentCollection = (PersistentCollection) collection; 52 } 53 54 if ( persistentCollection.wasInitialized() && persistentCollection.isDirty() ) { 55 dirty=true; 56 return null; } 58 } 59 60 return null; 61 } 62 63 boolean includeEntityProperty(Object [] values, int i) { 64 return propertyVersionability[i] && super.includeEntityProperty(values, i); 65 } 66 } 67 | Popular Tags |