HHH-7237 - Inline natural-id synchronization doesn't consider reattached objects

This commit is contained in:
Guenther Demetz 2012-04-10 14:47:50 +03:00 committed by Steve Ebersole
parent 572e78dce4
commit 76504f128f
1 changed files with 10 additions and 0 deletions

View File

@ -71,6 +71,7 @@ import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.PersistenceContext.NaturalIdHelper;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.ValueInclusion; import org.hibernate.engine.spi.ValueInclusion;
@ -3997,6 +3998,15 @@ public abstract class AbstractEntityPersister
fieldInterceptor.dirty(); fieldInterceptor.dirty();
} }
} }
if ( hasNaturalIdentifier() ) {
final Serializable id = getIdentifier( entity, session );
final NaturalIdHelper helper = session.getPersistenceContext().getNaturalIdHelper();
helper.cacheNaturalIdCrossReferenceFromLoad( // TODO rename cacheNaturalIdCrossReferenceFromLoad ?
this,
id,
helper.extractNaturalIdValues( getPropertyValues(entity), this )
);
}
} }
public Boolean isTransient(Object entity, SessionImplementor session) throws HibernateException { public Boolean isTransient(Object entity, SessionImplementor session) throws HibernateException {