HHH-13191 - Avoid LazyInitializationException when session is waiting for

auto-close with JPA_PROXY_COMPLIANCE enabled.
This commit is contained in:
Chris Cranford 2019-01-08 08:56:48 -05:00
parent 3cf2b50911
commit e07f1aa89b
1 changed files with 2 additions and 2 deletions

View File

@ -168,7 +168,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
else if ( session == null ) { else if ( session == null ) {
throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - no Session" ); throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - no Session" );
} }
else if ( !session.isOpen() ) { else if ( !session.isOpenOrWaitingForAutoClose() ) {
throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - the owning Session was closed" ); throw new LazyInitializationException( "could not initialize proxy [" + entityName + "#" + id + "] - the owning Session was closed" );
} }
else if ( !session.isConnected() ) { else if ( !session.isConnected() ) {
@ -344,7 +344,7 @@ public abstract class AbstractLazyInitializer implements LazyInitializer {
"Proxy [" + entityName + "#" + id + "] is detached (i.e, session is null). The read-only/modifiable setting is only accessible when the proxy is associated with an open session." "Proxy [" + entityName + "#" + id + "] is detached (i.e, session is null). The read-only/modifiable setting is only accessible when the proxy is associated with an open session."
); );
} }
if ( session.isClosed() ) { if ( !session.isOpenOrWaitingForAutoClose() ) {
throw new SessionException( throw new SessionException(
"Session is closed. The read-only/modifiable setting is only accessible when the proxy [" + entityName + "#" + id + "] is associated with an open session." "Session is closed. The read-only/modifiable setting is only accessible when the proxy [" + entityName + "#" + id + "] is associated with an open session."
); );