diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java index 4b7bc926d097..bbe089625d45 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractSaveEventListener.java @@ -412,7 +412,7 @@ protected boolean visitCollectionsBeforeSave( EventSource source) { final WrapVisitor visitor = new WrapVisitor( entity, id, source ); // substitutes into values by side effect - visitor.processEntityPropertyValues( values, types ); + visitor.processEntityPropertyValues( entity, values, types ); return visitor.isSubstitutionRequired(); } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractVisitor.java index 2a7bb58d6f5b..9e6f3dada9fe 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractVisitor.java @@ -7,6 +7,8 @@ import org.hibernate.HibernateException; import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer; import org.hibernate.event.spi.EventSource; +import org.hibernate.internal.CoreLogging; +import org.hibernate.internal.CoreMessageLogger; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.type.AnyType; import org.hibernate.type.CollectionType; @@ -25,6 +27,8 @@ */ public abstract class AbstractVisitor { + private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractVisitor.class ); + private final EventSource session; AbstractVisitor(EventSource session) { @@ -35,10 +39,10 @@ public abstract class AbstractVisitor { * Dispatch each property value to processValue(). * */ - void processValues(Object[] values, Type[] types) throws HibernateException { + void processValues(Object entity, Object[] values, Type[] types) throws HibernateException { for ( int i=0; i entity=" + entity + ", collection=" + collection + ", type=" + type); + } dirty = true; } } @@ -67,6 +75,9 @@ else if ( interceptor == null || interceptor.isAttributeLoaded( type.getName() ) // we need to check even if it was not initialized, because of delayed adds! if ( ((PersistentCollection) collection).isDirty() ) { + if (LOG.isTraceEnabled()) { + LOG.trace( "collection is dirty. interceptor == null -> entity=" + entity + ", collection=" + collection + ", type=" + type); + } dirty = true; } } @@ -76,6 +87,10 @@ else if ( interceptor == null || interceptor.isAttributeLoaded( type.getName() ) @Override boolean includeEntityProperty(Object[] values, int i) { - return propertyVersionability[i] && super.includeEntityProperty( values, i ); + boolean includeEntityProperty = super.includeEntityProperty( values, i ); + if (LOG.isTraceEnabled()) { + LOG.trace( "includeEntityProperty: i=" + i + ", propertyVersionability=" + propertyVersionability[i] + ", includeEntityProperty=" + includeEntityProperty ); + } + return propertyVersionability[i] && includeEntityProperty; } } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/EvictVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/EvictVisitor.java index 912fa6641cb4..697cdf9b03b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/EvictVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/EvictVisitor.java @@ -36,7 +36,7 @@ public EvictVisitor(EventSource session, Object owner) { } @Override - Object processCollection(Object collection, CollectionType type) throws HibernateException { + Object processCollection(Object entity, Object collection, CollectionType type) throws HibernateException { if ( collection != null ) { evictCollection( collection, type ); } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java index a5d8c02c35a9..5878ac903526 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/OnLockVisitor.java @@ -29,7 +29,7 @@ public OnLockVisitor(EventSource session, Object key, Object owner) { } @Override - public Object processCollection(Object collection, CollectionType type) throws HibernateException { + public Object processCollection(Object entity, Object collection, CollectionType type) throws HibernateException { if ( collection == null ) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/OnReplicateVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/OnReplicateVisitor.java index 64d13d580a52..03b5c30541d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/OnReplicateVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/OnReplicateVisitor.java @@ -32,7 +32,7 @@ public OnReplicateVisitor(EventSource session, Object key, Object owner, boolean } @Override - public Object processCollection(Object collection, CollectionType type) throws HibernateException { + public Object processCollection(Object entity, Object collection, CollectionType type) throws HibernateException { if ( collection == CollectionType.UNFETCHED_COLLECTION ) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java index 34a7b2b82524..6c6aee661f6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java @@ -27,7 +27,7 @@ public OnUpdateVisitor(EventSource session, Object key, Object owner) { } @Override - Object processCollection(Object collection, CollectionType type) throws HibernateException { + Object processCollection(Object entity, Object collection, CollectionType type) throws HibernateException { if ( collection == CollectionType.UNFETCHED_COLLECTION ) { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java index 98bfec85d695..e5141519228f 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/ProxyVisitor.java @@ -22,7 +22,7 @@ public ProxyVisitor(EventSource session) { super(session); } - Object processEntity(Object value, EntityType entityType) { + Object processEntity(Object entity, Object value, EntityType entityType) { if ( value != null ) { getSession().getPersistenceContext().reassociateIfUninitializedProxy( value ); // if it is an initialized proxy, let cascade diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/ReattachVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/ReattachVisitor.java index 019ba71701bd..8271c0d6fced 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/ReattachVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/ReattachVisitor.java @@ -55,13 +55,13 @@ final Object getOwner() { * {@inheritDoc} */ @Override - Object processComponent(Object component, CompositeType componentType) throws HibernateException { + Object processComponent(Object entity, Object component, CompositeType componentType) throws HibernateException { final Type[] types = componentType.getSubtypes(); if ( component == null ) { - processValues( new Object[types.length], types ); + processValues( entity, new Object[types.length], types ); } else { - super.processComponent( component, componentType ); + super.processComponent( entity, component, componentType ); } return null; diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/WrapVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/WrapVisitor.java index dc7d3691e405..8f6b9c5daa0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/WrapVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/WrapVisitor.java @@ -51,7 +51,7 @@ public boolean isSubstitutionRequired() { } @Override - protected Object processCollection(Object collection, CollectionType collectionType) + protected Object processCollection(Object entity, Object collection, CollectionType collectionType) throws HibernateException { if ( collection == null || collection == LazyPropertyInitializer.UNFETCHED_PROPERTY ) { return null; @@ -133,8 +133,8 @@ else if ( attributeInterceptor != null } @Override - protected void processValue(int i, Object[] values, Type[] types) { - final Object result = processValue( values[i], types[i] ); + protected void processValue(Object entity, int i, Object[] values, Type[] types) { + final Object result = processValue( values[i], values[i], types[i], i); if ( result != null ) { substitute = true; values[i] = result; @@ -142,13 +142,13 @@ protected void processValue(int i, Object[] values, Type[] types) { } @Override - protected Object processComponent(Object component, CompositeType componentType) throws HibernateException { + protected Object processComponent(Object entity, Object component, CompositeType componentType) throws HibernateException { if ( component != null ) { final Object[] values = componentType.getPropertyValues( component, getSession() ); final Type[] types = componentType.getSubtypes(); boolean substituteComponent = false; for ( int i = 0; i < types.length; i++ ) { - Object result = processValue( values[i], types[i] ); + Object result = processValue( values[i], values[i], types[i], i ); if ( result != null ) { values[i] = result; substituteComponent = true; @@ -166,7 +166,7 @@ protected Object processComponent(Object component, CompositeType componentType) public void process(Object object, EntityPersister persister) throws HibernateException { final Object[] values = persister.getValues( object ); final Type[] types = persister.getPropertyTypes(); - processEntityPropertyValues( values, types ); + processEntityPropertyValues( object, values, types ); if ( isSubstitutionRequired() ) { persister.setValues( object, values ); }