@@ -150,7 +150,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
150150
151151 private transient Transaction currentHibernateTransaction ;
152152 private transient TransactionCoordinator transactionCoordinator ;
153- private transient CacheTransactionSynchronization cacheTransactionSync ;
153+ private transient CacheTransactionSynchronization cacheTransactionSynchronization ;
154154
155155 private final boolean autoJoinTransactions ;
156156 private final boolean isTransactionCoordinatorShared ;
@@ -185,7 +185,7 @@ public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreation
185185 this .factoryOptions = factory .getSessionFactoryOptions ();
186186 this .jdbcServices = factory .getJdbcServices ();
187187
188- cacheTransactionSync = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
188+ cacheTransactionSynchronization = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
189189 tenantIdentifier = getTenantId ( factoryOptions , options );
190190 interceptor = interpret ( options .getInterceptor () );
191191 jdbcTimeZone = options .getJdbcTimeZone ();
@@ -310,7 +310,7 @@ private static SessionEventListenerManager createSessionEventsManager(
310310 public Integer getConfiguredJdbcBatchSize () {
311311 final Integer sessionJdbcBatchSize = jdbcBatchSize ;
312312 return sessionJdbcBatchSize == null
313- ? getSessionFactoryOptions () .getJdbcBatchSize ()
313+ ? factoryOptions .getJdbcBatchSize ()
314314 : sessionJdbcBatchSize ;
315315 }
316316
@@ -380,41 +380,41 @@ private StatementInspector interpret(StatementInspector statementInspector) {
380380 }
381381
382382 @ Override
383- public SessionFactoryImplementor getFactory () {
383+ public final SessionFactoryImplementor getFactory () {
384384 return factory ;
385385 }
386386
387387 @ Override
388- public Interceptor getInterceptor () {
388+ public final Interceptor getInterceptor () {
389389 return interceptor ;
390390 }
391391
392392 @ Override
393- public JdbcCoordinator getJdbcCoordinator () {
393+ public final JdbcCoordinator getJdbcCoordinator () {
394394 return jdbcCoordinator ;
395395 }
396396
397397 @ Override
398- public TransactionCoordinator getTransactionCoordinator () {
398+ public final TransactionCoordinator getTransactionCoordinator () {
399399 return transactionCoordinator ;
400400 }
401401
402402 @ Override
403- public JdbcSessionContext getJdbcSessionContext () {
403+ public final JdbcSessionContext getJdbcSessionContext () {
404404 return jdbcSessionContext ;
405405 }
406406
407- public EntityNameResolver getEntityNameResolver () {
407+ public final EntityNameResolver getEntityNameResolver () {
408408 return entityNameResolver ;
409409 }
410410
411411 @ Override
412- public SessionEventListenerManager getEventListenerManager () {
412+ public final SessionEventListenerManager getEventListenerManager () {
413413 return sessionEventsManager ;
414414 }
415415
416416 @ Override
417- public UUID getSessionIdentifier () {
417+ public final UUID getSessionIdentifier () {
418418 if ( sessionIdentifier == null ) {
419419 //Lazily initialized: otherwise all the UUID generations will cause significant amount of contention.
420420 sessionIdentifier = StandardRandomStrategy .INSTANCE .generateUUID ( null );
@@ -423,7 +423,7 @@ public UUID getSessionIdentifier() {
423423 }
424424
425425 @ Override
426- public Object getSessionToken () {
426+ public final Object getSessionToken () {
427427 if ( sessionToken == null ) {
428428 sessionToken = new Object ();
429429 }
@@ -439,7 +439,7 @@ public String getTenantIdentifier() {
439439 }
440440
441441 @ Override
442- public Object getTenantIdentifierValue () {
442+ public final Object getTenantIdentifierValue () {
443443 return tenantIdentifier ;
444444 }
445445
@@ -460,7 +460,7 @@ public void close() {
460460 delayedAfterCompletion ();
461461 }
462462 catch ( HibernateException e ) {
463- if ( getSessionFactoryOptions () .isJpaBootstrap () ) {
463+ if ( factoryOptions .isJpaBootstrap () ) {
464464 throw getExceptionConverter ().convert ( e );
465465 }
466466 else {
@@ -503,7 +503,8 @@ protected void cleanupOnClose() {
503503
504504 @ Override
505505 public boolean isOpenOrWaitingForAutoClose () {
506- return !isClosed () || waitingForAutoClose ;
506+ return !closed && factory .isOpen ()
507+ || waitingForAutoClose ;
507508 }
508509
509510 @ Override
@@ -540,14 +541,13 @@ public void markForRollbackOnly() {
540541
541542 @ Override
542543 public boolean isTransactionInProgress () {
543- return waitingForAutoClose
544- ? factory .isOpen () && transactionCoordinator .isTransactionActive ()
545- : !isClosed () && transactionCoordinator .isTransactionActive ();
544+ return isOpenOrWaitingForAutoClose ()
545+ && transactionCoordinator .isTransactionActive ();
546546 }
547547
548548 @ Override
549549 public void checkTransactionNeededForUpdateOperation (String exceptionMessage ) {
550- if ( !getSessionFactoryOptions () .isAllowOutOfTransactionUpdateOperations ()
550+ if ( !factoryOptions .isAllowOutOfTransactionUpdateOperations ()
551551 && !isTransactionInProgress () ) {
552552 throw new TransactionRequiredException ( exceptionMessage );
553553 }
@@ -556,9 +556,8 @@ public void checkTransactionNeededForUpdateOperation(String exceptionMessage) {
556556 private boolean isTransactionAccessible () {
557557 // JPA requires that access not be provided to the transaction when using JTA.
558558 // This is overridden when SessionFactoryOptions isJtaTransactionAccessEnabled() is true.
559- final SessionFactoryOptions sessionFactoryOptions = getSessionFactoryOptions ();
560- return sessionFactoryOptions .isJtaTransactionAccessEnabled () // defaults to false in JPA bootstrap
561- || !sessionFactoryOptions .getJpaCompliance ().isJpaTransactionComplianceEnabled ()
559+ return factoryOptions .isJtaTransactionAccessEnabled () // defaults to false in JPA bootstrap
560+ || !factoryOptions .getJpaCompliance ().isJpaTransactionComplianceEnabled ()
562561 || !factory .transactionCoordinatorBuilder .isJta ();
563562 }
564563
@@ -577,30 +576,30 @@ public Transaction accessTransaction() {
577576 if ( currentHibernateTransaction == null ) {
578577 currentHibernateTransaction = new TransactionImpl ( getTransactionCoordinator (), this );
579578 }
580- if ( ! isClosed () || waitingForAutoClose && factory . isOpen () ) {
581- getTransactionCoordinator () .pulse ();
579+ if ( isOpenOrWaitingForAutoClose () ) {
580+ transactionCoordinator .pulse ();
582581 }
583582 return currentHibernateTransaction ;
584583 }
585584
586585 @ Override
587586 public void startTransactionBoundary () {
588- getCacheTransactionSynchronization () .transactionJoined ();
587+ cacheTransactionSynchronization .transactionJoined ();
589588 }
590589
591590 @ Override
592591 public void beforeTransactionCompletion () {
593- getCacheTransactionSynchronization () .transactionCompleting ();
592+ cacheTransactionSynchronization .transactionCompleting ();
594593 }
595594
596595 @ Override
597596 public void afterTransactionCompletion (boolean successful , boolean delayed ) {
598- getCacheTransactionSynchronization () .transactionCompleted ( successful );
597+ cacheTransactionSynchronization .transactionCompleted ( successful );
599598 }
600599
601600 @ Override
602- public CacheTransactionSynchronization getCacheTransactionSynchronization () {
603- return cacheTransactionSync ;
601+ public final CacheTransactionSynchronization getCacheTransactionSynchronization () {
602+ return cacheTransactionSynchronization ;
604603 }
605604
606605 @ Override
@@ -637,26 +636,26 @@ protected void pulseTransactionCoordinator() {
637636 @ Override
638637 public void joinTransaction () {
639638 checkOpen ();
640- if ( !getTransactionCoordinator () .getTransactionCoordinatorBuilder ().isJta () ) {
639+ if ( !transactionCoordinator .getTransactionCoordinatorBuilder ().isJta () ) {
641640 log .callingJoinTransactionOnNonJtaEntityManager ();
642- return ;
643641 }
644-
645- try {
646- getTransactionCoordinator ().explicitJoin ();
647- }
648- catch ( TransactionRequiredForJoinException e ) {
649- throw new TransactionRequiredException ( e .getMessage () );
650- }
651- catch ( HibernateException he ) {
652- throw getExceptionConverter ().convert ( he );
642+ else {
643+ try {
644+ transactionCoordinator .explicitJoin ();
645+ }
646+ catch ( TransactionRequiredForJoinException e ) {
647+ throw new TransactionRequiredException ( e .getMessage () );
648+ }
649+ catch ( HibernateException he ) {
650+ throw getExceptionConverter ().convert ( he );
651+ }
653652 }
654653 }
655654
656655 @ Override
657656 public boolean isJoinedToTransaction () {
658657 checkOpen ();
659- return getTransactionCoordinator () .isJoined ();
658+ return transactionCoordinator .isJoined ();
660659 }
661660
662661 protected void delayedAfterCompletion () {
@@ -679,17 +678,17 @@ public boolean isConnected() {
679678 public JdbcConnectionAccess getJdbcConnectionAccess () {
680679 // See class-level JavaDocs for a discussion of the concurrent-access safety of this method
681680 if ( jdbcConnectionAccess == null ) {
682- if ( !getSessionFactoryOptions () .isMultiTenancyEnabled () ) {
681+ if ( !factoryOptions .isMultiTenancyEnabled () ) {
683682 jdbcConnectionAccess = new NonContextualJdbcConnectionAccess (
684- getEventListenerManager () ,
683+ sessionEventsManager ,
685684 factory .connectionProvider ,
686685 this
687686 );
688687 }
689688 else {
690689 jdbcConnectionAccess = new ContextualJdbcConnectionAccess (
691- getTenantIdentifierValue () ,
692- getEventListenerManager () ,
690+ tenantIdentifier ,
691+ sessionEventsManager ,
693692 factory .multiTenantConnectionProvider ,
694693 this
695694 );
@@ -704,28 +703,28 @@ public EntityKey generateEntityKey(Object id, EntityPersister persister) {
704703 }
705704
706705 @ Override
707- public SessionFactoryImplementor getSessionFactory () {
706+ public final SessionFactoryImplementor getSessionFactory () {
708707 return factory ;
709708 }
710709
711710 @ Override
712711 public boolean useStreamForLobBinding () {
713- return getJdbcServices (). getJdbcEnvironment (). getDialect ().useInputStreamToInsertBlob ();
712+ return getDialect ().useInputStreamToInsertBlob ();
714713 }
715714
716715 @ Override
717716 public int getPreferredSqlTypeCodeForBoolean () {
718- return getSessionFactoryOptions () .getPreferredSqlTypeCodeForBoolean ();
717+ return factoryOptions .getPreferredSqlTypeCodeForBoolean ();
719718 }
720719
721720 @ Override
722721 public LobCreator getLobCreator () {
723- return getJdbcServices () .getLobCreator ( this );
722+ return jdbcServices .getLobCreator ( this );
724723 }
725724
726725 @ Override
727726 public Dialect getDialect () {
728- return getJdbcServices () .getJdbcEnvironment ().getDialect ();
727+ return jdbcServices .getJdbcEnvironment ().getDialect ();
729728 }
730729
731730 @ Override
@@ -756,7 +755,7 @@ public TimeZone getJdbcTimeZone() {
756755 }
757756
758757 @ Override
759- public JdbcServices getJdbcServices () {
758+ public final JdbcServices getJdbcServices () {
760759 return jdbcServices ;
761760 }
762761
@@ -1579,12 +1578,12 @@ public void disableFilter(String filterName) {
15791578
15801579 @ Override
15811580 public FormatMapper getXmlFormatMapper () {
1582- return getSessionFactoryOptions () .getXmlFormatMapper ();
1581+ return factoryOptions .getXmlFormatMapper ();
15831582 }
15841583
15851584 @ Override
15861585 public FormatMapper getJsonFormatMapper () {
1587- return getSessionFactoryOptions () .getJsonFormatMapper ();
1586+ return factoryOptions .getJsonFormatMapper ();
15881587 }
15891588
15901589 @ Serial
@@ -1647,7 +1646,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
16471646 jdbcSessionContext = createJdbcSessionContext ( (StatementInspector ) ois .readObject () );
16481647 jdbcCoordinator = JdbcCoordinatorImpl .deserialize ( ois , this );
16491648
1650- cacheTransactionSync = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
1649+ cacheTransactionSynchronization = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
16511650 transactionCoordinator =
16521651 factory .transactionCoordinatorBuilder .buildTransactionCoordinator ( jdbcCoordinator , this );
16531652
0 commit comments