Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11602

Session close counter statistic not updated when using Hibernate in JPA mode

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 5.2.7
    • Fix Version/s: 5.2.10
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Hibernate 5.2.x used in JPA mode, Oracle 11g
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • Last commented by a user?:
      true

      Description

      When using hibernate in JPA mode with statistics enabled, the session close statistic is not updated.
      Giving a look in the close() method of SessionImpl

      if ( getSessionFactory().getSessionFactoryOptions().isJpaBootstrap() ) {
      			// Original hibernate-entitymanager EM#close behavior
      			checkSessionFactoryOpen();
      			checkOpenOrWaitingForAutoClose();
      			if ( discardOnClose || !isTransactionInProgress( false ) ) {
      				super.close();
      			}
      			else {
      				//Otherwise, session auto-close will be enabled by shouldAutoCloseSession().
      				waitingForAutoClose = true;
      				closed = true;
      			}
      		}
      		else {
      
      			super.close();
      
      			if ( getFactory().getStatistics().isStatisticsEnabled() ) {
      				getFactory().getStatistics().closeSession();
      			}
      		}
      

      we can see that getFactory().getStatistics().closeSession(); is only called in native mode

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: