@@ -397,7 +397,7 @@ private ClearEvent createClearEvent() {
397397 public void close () throws HibernateException {
398398 if ( isClosed () ) {
399399 if ( getFactory ().getSessionFactoryOptions ().getJpaCompliance ().isJpaClosedComplianceEnabled () ) {
400- throw new IllegalStateException ( "Illegal call to #close() on already closed Session/EntityManager " );
400+ throw new IllegalStateException ( "EntityManager was already closed" );
401401 }
402402 log .trace ( "Already closed" );
403403 }
@@ -465,13 +465,10 @@ protected boolean shouldCloseJdbcCoordinatorOnClose(boolean isTransactionCoordin
465465 if ( isTransactionCoordinatorShared ) {
466466 final ActionQueue actionQueue = getActionQueue ();
467467 if ( actionQueue .hasBeforeTransactionActions () || actionQueue .hasAfterTransactionActions () ) {
468- log .warn ( "On close, shared Session had before/after transaction actions that have not yet been processed " );
468+ log .warn ( "Closing shared session with unprocessed transaction completion actions " );
469469 }
470- return false ;
471- }
472- else {
473- return true ;
474470 }
471+ return !isTransactionCoordinatorShared ;
475472 }
476473
477474 @ Override
@@ -493,18 +490,19 @@ public boolean isOpen() {
493490
494491 protected void checkSessionFactoryOpen () {
495492 if ( !getFactory ().isOpen () ) {
496- log .debug ( "Forcing Session/EntityManager closed as SessionFactory/EntityManagerFactory has been closed" );
493+ log .debug ( "Forcing-closing session since factory is already closed" );
497494 setClosed ();
498495 }
499496 }
500497
501498 private void managedFlush () {
502499 if ( isClosed () && !waitingForAutoClose ) {
503- log .trace ( "Skipping auto-flush due to session closed" );
504- return ;
500+ log .trace ( "Skipping auto-flush since the session is closed" );
501+ }
502+ else {
503+ log .trace ( "Automatically flushing session" );
504+ doFlush ();
505505 }
506- log .trace ( "Automatically flushing session" );
507- doFlush ();
508506 }
509507
510508 @ Override
0 commit comments