1 package org.hibernate.event.def; 3 4 import java.io.Serializable ; 5 6 import org.apache.commons.logging.Log; 7 import org.apache.commons.logging.LogFactory; 8 import org.hibernate.HibernateException; 9 import org.hibernate.action.CollectionRemoveAction; 10 import org.hibernate.event.EventSource; 11 import org.hibernate.persister.collection.CollectionPersister; 12 import org.hibernate.pretty.MessageHelper; 13 import org.hibernate.type.AbstractComponentType; 14 import org.hibernate.type.Type; 15 16 20 public abstract class ReattachVisitor extends ProxyVisitor { 21 22 private static final Log log = LogFactory.getLog(ReattachVisitor.class); 23 24 private final Serializable key; 25 26 final Serializable getKey() { 27 return key; 28 } 29 30 public ReattachVisitor(EventSource session, Serializable key) { 31 super(session); 32 this.key=key; 33 } 34 35 Object processComponent(Object component, AbstractComponentType componentType) 36 throws HibernateException { 37 38 Type[] types = componentType.getSubtypes(); 39 if (component==null) { 40 processValues( new Object [types.length], types ); 41 } 42 else { 43 super.processComponent(component, componentType); 44 } 46 47 return null; 48 } 49 50 57 public void removeCollection(CollectionPersister role, Serializable id, EventSource source) 58 throws HibernateException { 59 if ( log.isTraceEnabled() ) 60 log.trace( 61 "collection dereferenced while transient " + 62 MessageHelper.collectionInfoString( role, id, source.getFactory() ) 63 ); 64 70 source.getActionQueue().addAction( new CollectionRemoveAction( null, role, id, false, source ) ); 71 } 72 73 } 74 | Popular Tags |