HHH-11147 Fix initializing an entity that does not exist
This commit is contained in:
parent
0bc1d5a88c
commit
beb4c3891c
|
@ -4320,16 +4320,28 @@ public abstract class AbstractEntityPersister
|
||||||
if ( currentInterceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
|
if ( currentInterceptor instanceof EnhancementAsProxyLazinessInterceptor ) {
|
||||||
final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) currentInterceptor;
|
final EnhancementAsProxyLazinessInterceptor proxyInterceptor = (EnhancementAsProxyLazinessInterceptor) currentInterceptor;
|
||||||
|
|
||||||
readLockLoader.load(
|
final EntityKey entityKey = proxyInterceptor.getEntityKey();
|
||||||
proxyInterceptor.getEntityKey().getIdentifier(),
|
final Serializable identifier = entityKey.getIdentifier();
|
||||||
|
final Object loaded = readLockLoader.load(
|
||||||
|
identifier,
|
||||||
entity,
|
entity,
|
||||||
session,
|
session,
|
||||||
LockOptions.READ
|
LockOptions.READ
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( loaded == null ) {
|
||||||
|
final PersistenceContext persistenceContext = session.getPersistenceContext();
|
||||||
|
persistenceContext.removeEntry( entity );
|
||||||
|
persistenceContext.removeEntity( entityKey );
|
||||||
|
session.getFactory().getEntityNotFoundDelegate().handleEntityNotFound(
|
||||||
|
entityKey.getEntityName(),
|
||||||
|
identifier
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
final LazyAttributeLoadingInterceptor interceptor = enhancementMetadata.injectInterceptor(
|
final LazyAttributeLoadingInterceptor interceptor = enhancementMetadata.injectInterceptor(
|
||||||
entity,
|
entity,
|
||||||
proxyInterceptor.getEntityKey().getIdentifier(),
|
identifier,
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue