@@ -150,7 +150,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
150
150
151
151
private transient Transaction currentHibernateTransaction ;
152
152
private transient TransactionCoordinator transactionCoordinator ;
153
- private transient CacheTransactionSynchronization cacheTransactionSync ;
153
+ private transient CacheTransactionSynchronization cacheTransactionSynchronization ;
154
154
155
155
private final boolean autoJoinTransactions ;
156
156
private final boolean isTransactionCoordinatorShared ;
@@ -185,7 +185,7 @@ public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreation
185
185
this .factoryOptions = factory .getSessionFactoryOptions ();
186
186
this .jdbcServices = factory .getJdbcServices ();
187
187
188
- cacheTransactionSync = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
188
+ cacheTransactionSynchronization = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
189
189
tenantIdentifier = getTenantId ( factoryOptions , options );
190
190
interceptor = interpret ( options .getInterceptor () );
191
191
jdbcTimeZone = options .getJdbcTimeZone ();
@@ -310,7 +310,7 @@ private static SessionEventListenerManager createSessionEventsManager(
310
310
public Integer getConfiguredJdbcBatchSize () {
311
311
final Integer sessionJdbcBatchSize = jdbcBatchSize ;
312
312
return sessionJdbcBatchSize == null
313
- ? getSessionFactoryOptions () .getJdbcBatchSize ()
313
+ ? factoryOptions .getJdbcBatchSize ()
314
314
: sessionJdbcBatchSize ;
315
315
}
316
316
@@ -380,41 +380,41 @@ private StatementInspector interpret(StatementInspector statementInspector) {
380
380
}
381
381
382
382
@ Override
383
- public SessionFactoryImplementor getFactory () {
383
+ public final SessionFactoryImplementor getFactory () {
384
384
return factory ;
385
385
}
386
386
387
387
@ Override
388
- public Interceptor getInterceptor () {
388
+ public final Interceptor getInterceptor () {
389
389
return interceptor ;
390
390
}
391
391
392
392
@ Override
393
- public JdbcCoordinator getJdbcCoordinator () {
393
+ public final JdbcCoordinator getJdbcCoordinator () {
394
394
return jdbcCoordinator ;
395
395
}
396
396
397
397
@ Override
398
- public TransactionCoordinator getTransactionCoordinator () {
398
+ public final TransactionCoordinator getTransactionCoordinator () {
399
399
return transactionCoordinator ;
400
400
}
401
401
402
402
@ Override
403
- public JdbcSessionContext getJdbcSessionContext () {
403
+ public final JdbcSessionContext getJdbcSessionContext () {
404
404
return jdbcSessionContext ;
405
405
}
406
406
407
- public EntityNameResolver getEntityNameResolver () {
407
+ public final EntityNameResolver getEntityNameResolver () {
408
408
return entityNameResolver ;
409
409
}
410
410
411
411
@ Override
412
- public SessionEventListenerManager getEventListenerManager () {
412
+ public final SessionEventListenerManager getEventListenerManager () {
413
413
return sessionEventsManager ;
414
414
}
415
415
416
416
@ Override
417
- public UUID getSessionIdentifier () {
417
+ public final UUID getSessionIdentifier () {
418
418
if ( sessionIdentifier == null ) {
419
419
//Lazily initialized: otherwise all the UUID generations will cause significant amount of contention.
420
420
sessionIdentifier = StandardRandomStrategy .INSTANCE .generateUUID ( null );
@@ -423,7 +423,7 @@ public UUID getSessionIdentifier() {
423
423
}
424
424
425
425
@ Override
426
- public Object getSessionToken () {
426
+ public final Object getSessionToken () {
427
427
if ( sessionToken == null ) {
428
428
sessionToken = new Object ();
429
429
}
@@ -439,7 +439,7 @@ public String getTenantIdentifier() {
439
439
}
440
440
441
441
@ Override
442
- public Object getTenantIdentifierValue () {
442
+ public final Object getTenantIdentifierValue () {
443
443
return tenantIdentifier ;
444
444
}
445
445
@@ -460,7 +460,7 @@ public void close() {
460
460
delayedAfterCompletion ();
461
461
}
462
462
catch ( HibernateException e ) {
463
- if ( getSessionFactoryOptions () .isJpaBootstrap () ) {
463
+ if ( factoryOptions .isJpaBootstrap () ) {
464
464
throw getExceptionConverter ().convert ( e );
465
465
}
466
466
else {
@@ -503,7 +503,8 @@ protected void cleanupOnClose() {
503
503
504
504
@ Override
505
505
public boolean isOpenOrWaitingForAutoClose () {
506
- return !isClosed () || waitingForAutoClose ;
506
+ return !closed && factory .isOpen ()
507
+ || waitingForAutoClose ;
507
508
}
508
509
509
510
@ Override
@@ -540,14 +541,13 @@ public void markForRollbackOnly() {
540
541
541
542
@ Override
542
543
public boolean isTransactionInProgress () {
543
- return waitingForAutoClose
544
- ? factory .isOpen () && transactionCoordinator .isTransactionActive ()
545
- : !isClosed () && transactionCoordinator .isTransactionActive ();
544
+ return isOpenOrWaitingForAutoClose ()
545
+ && transactionCoordinator .isTransactionActive ();
546
546
}
547
547
548
548
@ Override
549
549
public void checkTransactionNeededForUpdateOperation (String exceptionMessage ) {
550
- if ( !getSessionFactoryOptions () .isAllowOutOfTransactionUpdateOperations ()
550
+ if ( !factoryOptions .isAllowOutOfTransactionUpdateOperations ()
551
551
&& !isTransactionInProgress () ) {
552
552
throw new TransactionRequiredException ( exceptionMessage );
553
553
}
@@ -556,9 +556,8 @@ public void checkTransactionNeededForUpdateOperation(String exceptionMessage) {
556
556
private boolean isTransactionAccessible () {
557
557
// JPA requires that access not be provided to the transaction when using JTA.
558
558
// 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 ()
562
561
|| !factory .transactionCoordinatorBuilder .isJta ();
563
562
}
564
563
@@ -577,30 +576,30 @@ public Transaction accessTransaction() {
577
576
if ( currentHibernateTransaction == null ) {
578
577
currentHibernateTransaction = new TransactionImpl ( getTransactionCoordinator (), this );
579
578
}
580
- if ( ! isClosed () || waitingForAutoClose && factory . isOpen () ) {
581
- getTransactionCoordinator () .pulse ();
579
+ if ( isOpenOrWaitingForAutoClose () ) {
580
+ transactionCoordinator .pulse ();
582
581
}
583
582
return currentHibernateTransaction ;
584
583
}
585
584
586
585
@ Override
587
586
public void startTransactionBoundary () {
588
- getCacheTransactionSynchronization () .transactionJoined ();
587
+ cacheTransactionSynchronization .transactionJoined ();
589
588
}
590
589
591
590
@ Override
592
591
public void beforeTransactionCompletion () {
593
- getCacheTransactionSynchronization () .transactionCompleting ();
592
+ cacheTransactionSynchronization .transactionCompleting ();
594
593
}
595
594
596
595
@ Override
597
596
public void afterTransactionCompletion (boolean successful , boolean delayed ) {
598
- getCacheTransactionSynchronization () .transactionCompleted ( successful );
597
+ cacheTransactionSynchronization .transactionCompleted ( successful );
599
598
}
600
599
601
600
@ Override
602
- public CacheTransactionSynchronization getCacheTransactionSynchronization () {
603
- return cacheTransactionSync ;
601
+ public final CacheTransactionSynchronization getCacheTransactionSynchronization () {
602
+ return cacheTransactionSynchronization ;
604
603
}
605
604
606
605
@ Override
@@ -637,26 +636,26 @@ protected void pulseTransactionCoordinator() {
637
636
@ Override
638
637
public void joinTransaction () {
639
638
checkOpen ();
640
- if ( !getTransactionCoordinator () .getTransactionCoordinatorBuilder ().isJta () ) {
639
+ if ( !transactionCoordinator .getTransactionCoordinatorBuilder ().isJta () ) {
641
640
log .callingJoinTransactionOnNonJtaEntityManager ();
642
- return ;
643
641
}
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
+ }
653
652
}
654
653
}
655
654
656
655
@ Override
657
656
public boolean isJoinedToTransaction () {
658
657
checkOpen ();
659
- return getTransactionCoordinator () .isJoined ();
658
+ return transactionCoordinator .isJoined ();
660
659
}
661
660
662
661
protected void delayedAfterCompletion () {
@@ -679,17 +678,17 @@ public boolean isConnected() {
679
678
public JdbcConnectionAccess getJdbcConnectionAccess () {
680
679
// See class-level JavaDocs for a discussion of the concurrent-access safety of this method
681
680
if ( jdbcConnectionAccess == null ) {
682
- if ( !getSessionFactoryOptions () .isMultiTenancyEnabled () ) {
681
+ if ( !factoryOptions .isMultiTenancyEnabled () ) {
683
682
jdbcConnectionAccess = new NonContextualJdbcConnectionAccess (
684
- getEventListenerManager () ,
683
+ sessionEventsManager ,
685
684
factory .connectionProvider ,
686
685
this
687
686
);
688
687
}
689
688
else {
690
689
jdbcConnectionAccess = new ContextualJdbcConnectionAccess (
691
- getTenantIdentifierValue () ,
692
- getEventListenerManager () ,
690
+ tenantIdentifier ,
691
+ sessionEventsManager ,
693
692
factory .multiTenantConnectionProvider ,
694
693
this
695
694
);
@@ -704,28 +703,28 @@ public EntityKey generateEntityKey(Object id, EntityPersister persister) {
704
703
}
705
704
706
705
@ Override
707
- public SessionFactoryImplementor getSessionFactory () {
706
+ public final SessionFactoryImplementor getSessionFactory () {
708
707
return factory ;
709
708
}
710
709
711
710
@ Override
712
711
public boolean useStreamForLobBinding () {
713
- return getJdbcServices (). getJdbcEnvironment (). getDialect ().useInputStreamToInsertBlob ();
712
+ return getDialect ().useInputStreamToInsertBlob ();
714
713
}
715
714
716
715
@ Override
717
716
public int getPreferredSqlTypeCodeForBoolean () {
718
- return getSessionFactoryOptions () .getPreferredSqlTypeCodeForBoolean ();
717
+ return factoryOptions .getPreferredSqlTypeCodeForBoolean ();
719
718
}
720
719
721
720
@ Override
722
721
public LobCreator getLobCreator () {
723
- return getJdbcServices () .getLobCreator ( this );
722
+ return jdbcServices .getLobCreator ( this );
724
723
}
725
724
726
725
@ Override
727
726
public Dialect getDialect () {
728
- return getJdbcServices () .getJdbcEnvironment ().getDialect ();
727
+ return jdbcServices .getJdbcEnvironment ().getDialect ();
729
728
}
730
729
731
730
@ Override
@@ -756,7 +755,7 @@ public TimeZone getJdbcTimeZone() {
756
755
}
757
756
758
757
@ Override
759
- public JdbcServices getJdbcServices () {
758
+ public final JdbcServices getJdbcServices () {
760
759
return jdbcServices ;
761
760
}
762
761
@@ -1579,12 +1578,12 @@ public void disableFilter(String filterName) {
1579
1578
1580
1579
@ Override
1581
1580
public FormatMapper getXmlFormatMapper () {
1582
- return getSessionFactoryOptions () .getXmlFormatMapper ();
1581
+ return factoryOptions .getXmlFormatMapper ();
1583
1582
}
1584
1583
1585
1584
@ Override
1586
1585
public FormatMapper getJsonFormatMapper () {
1587
- return getSessionFactoryOptions () .getJsonFormatMapper ();
1586
+ return factoryOptions .getJsonFormatMapper ();
1588
1587
}
1589
1588
1590
1589
@ Serial
@@ -1647,7 +1646,7 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
1647
1646
jdbcSessionContext = createJdbcSessionContext ( (StatementInspector ) ois .readObject () );
1648
1647
jdbcCoordinator = JdbcCoordinatorImpl .deserialize ( ois , this );
1649
1648
1650
- cacheTransactionSync = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
1649
+ cacheTransactionSynchronization = factory .getCache ().getRegionFactory ().createTransactionContext ( this );
1651
1650
transactionCoordinator =
1652
1651
factory .transactionCoordinatorBuilder .buildTransactionCoordinator ( jdbcCoordinator , this );
1653
1652
0 commit comments