HHH-9857 - Reuse of EntityEntry for bytecode enhanced read-only reference cached entities
This commit is contained in:
parent
d29b55a31a
commit
3a515b5d39
|
@ -44,6 +44,7 @@ import org.hibernate.engine.spi.EntityEntry;
|
|||
import org.hibernate.engine.spi.EntityEntryFactory;
|
||||
import org.hibernate.engine.spi.EntityKey;
|
||||
import org.hibernate.engine.spi.EntityUniqueKey;
|
||||
import org.hibernate.engine.spi.ManagedEntity;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
|
@ -472,8 +473,15 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
final boolean disableVersionIncrement,
|
||||
boolean lazyPropertiesAreUnfetched) {
|
||||
|
||||
final EntityEntry e;
|
||||
|
||||
if( (entity instanceof ManagedEntity) && ((ManagedEntity) entity).$$_hibernate_getEntityEntry() != null && status == Status.READ_ONLY) {
|
||||
e = ((ManagedEntity) entity).$$_hibernate_getEntityEntry();
|
||||
e.setStatus( status );
|
||||
}
|
||||
else {
|
||||
final EntityEntryFactory entityEntryFactory = persister.getEntityEntryFactory();
|
||||
final EntityEntry e = entityEntryFactory.createEntityEntry(
|
||||
e = entityEntryFactory.createEntityEntry(
|
||||
status,
|
||||
loadedState,
|
||||
rowId,
|
||||
|
@ -486,6 +494,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
|
|||
lazyPropertiesAreUnfetched,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
entityEntryContext.addEntityEntry( entity, e );
|
||||
// entityEntries.put(entity, e);
|
||||
|
|
Loading…
Reference in New Issue