68
68
import org .hibernate .resource .transaction .spi .TransactionCoordinatorBuilder ;
69
69
import org .hibernate .stat .Statistics ;
70
70
import org .hibernate .type .format .FormatMapper ;
71
- import org .hibernate .type .format .jackson .JacksonIntegration ;
72
- import org .hibernate .type .format .jakartajson .JakartaJsonIntegration ;
73
71
import org .hibernate .type .format .jaxb .JaxbXmlFormatMapper ;
74
72
75
73
import jakarta .persistence .criteria .Nulls ;
142
140
import static org .hibernate .internal .util .config .ConfigurationHelper .getInt ;
143
141
import static org .hibernate .internal .util .config .ConfigurationHelper .getInteger ;
144
142
import static org .hibernate .internal .util .config .ConfigurationHelper .getString ;
143
+ import static org .hibernate .type .format .jackson .JacksonIntegration .getJsonJacksonFormatMapperOrNull ;
144
+ import static org .hibernate .type .format .jackson .JacksonIntegration .getXMLJacksonFormatMapperOrNull ;
145
+ import static org .hibernate .type .format .jakartajson .JakartaJsonIntegration .getJakartaJsonBFormatMapperOrNull ;
145
146
146
147
/**
147
148
* In-flight state of {@link SessionFactoryOptions} during {@link org.hibernate.boot.SessionFactoryBuilder}
@@ -648,10 +649,7 @@ else if ( jdbcTimeZoneValue != null ) {
648
649
649
650
private boolean disallowBatchUpdates (Dialect dialect , ExtractedDatabaseMetaData meta ) {
650
651
final Boolean dialectAnswer = dialect .supportsBatchUpdates ();
651
- if ( dialectAnswer != null ) {
652
- return !dialectAnswer ;
653
- }
654
- return !meta .supportsBatchUpdates ();
652
+ return dialectAnswer != null ? !dialectAnswer : !meta .supportsBatchUpdates ();
655
653
}
656
654
657
655
@ SuppressWarnings ("unchecked" )
@@ -759,19 +757,20 @@ private HqlTranslator resolveHqlTranslator(
759
757
if ( isEmpty ( producerName ) ) {
760
758
return null ;
761
759
}
762
-
763
- //noinspection Convert2Lambda
764
- return strategySelector .resolveDefaultableStrategy (
765
- HqlTranslator .class ,
766
- producerName ,
767
- new Callable <>() {
768
- @ Override
769
- public HqlTranslator call () throws Exception {
770
- return (HqlTranslator ) serviceRegistry .requireService ( ClassLoaderService .class )
771
- .classForName ( producerName ).newInstance ();
760
+ else {
761
+ //noinspection Convert2Lambda
762
+ return strategySelector .resolveDefaultableStrategy (
763
+ HqlTranslator .class ,
764
+ producerName ,
765
+ new Callable <>() {
766
+ @ Override
767
+ public HqlTranslator call () throws Exception {
768
+ return (HqlTranslator ) serviceRegistry .requireService ( ClassLoaderService .class )
769
+ .classForName ( producerName ).newInstance ();
770
+ }
772
771
}
773
- }
774
- );
772
+ );
773
+ }
775
774
}
776
775
777
776
private SqmTranslatorFactory resolveSqmTranslator (
@@ -780,21 +779,20 @@ private SqmTranslatorFactory resolveSqmTranslator(
780
779
if ( isEmpty ( translatorImplFqn ) ) {
781
780
return null ;
782
781
}
783
-
784
- return strategySelector .resolveStrategy (
785
- SqmTranslatorFactory .class ,
786
- translatorImplFqn
787
- );
782
+ else {
783
+ return strategySelector .resolveStrategy (
784
+ SqmTranslatorFactory .class ,
785
+ translatorImplFqn
786
+ );
787
+ }
788
788
}
789
789
790
790
private static Interceptor determineInterceptor (
791
791
Map <String ,Object > configurationSettings ,
792
792
StrategySelector strategySelector ) {
793
- Object setting = configurationSettings .get ( INTERCEPTOR );
794
-
795
793
return strategySelector .resolveStrategy (
796
794
Interceptor .class ,
797
- setting
795
+ configurationSettings . get ( INTERCEPTOR )
798
796
);
799
797
}
800
798
@@ -811,8 +809,7 @@ else if ( setting instanceof Supplier ) {
811
809
return (Supplier <? extends Interceptor >) setting ;
812
810
}
813
811
else if ( setting instanceof Class ) {
814
- Class <? extends Interceptor > clazz = (Class <? extends Interceptor >) setting ;
815
- return interceptorSupplier ( clazz );
812
+ return interceptorSupplier ( (Class <? extends Interceptor >) setting );
816
813
}
817
814
else {
818
815
return interceptorSupplier (
@@ -839,29 +836,21 @@ private static Supplier<? extends Interceptor> interceptorSupplier(Class<? exten
839
836
private PhysicalConnectionHandlingMode interpretConnectionHandlingMode (
840
837
Map <String ,Object > configurationSettings ,
841
838
StandardServiceRegistry serviceRegistry ) {
842
- final PhysicalConnectionHandlingMode specifiedHandlingMode = PhysicalConnectionHandlingMode .interpret (
843
- configurationSettings .get ( CONNECTION_HANDLING )
844
- );
845
-
846
- if ( specifiedHandlingMode != null ) {
847
- return specifiedHandlingMode ;
848
- }
849
-
850
- return serviceRegistry .requireService ( TransactionCoordinatorBuilder .class ).getDefaultConnectionHandlingMode ();
839
+ final PhysicalConnectionHandlingMode specifiedHandlingMode =
840
+ PhysicalConnectionHandlingMode .interpret ( configurationSettings .get ( CONNECTION_HANDLING ) );
841
+ return specifiedHandlingMode != null
842
+ ? specifiedHandlingMode
843
+ : serviceRegistry .requireService ( TransactionCoordinatorBuilder .class )
844
+ .getDefaultConnectionHandlingMode ();
851
845
}
852
846
853
847
private static FormatMapper determineJsonFormatMapper (Object setting , StrategySelector strategySelector ) {
854
848
return strategySelector .resolveDefaultableStrategy (
855
849
FormatMapper .class ,
856
850
setting ,
857
851
(Callable <FormatMapper >) () -> {
858
- final FormatMapper jsonJacksonFormatMapper = JacksonIntegration .getJsonJacksonFormatMapperOrNull ();
859
- if (jsonJacksonFormatMapper != null ) {
860
- return jsonJacksonFormatMapper ;
861
- }
862
- else {
863
- return JakartaJsonIntegration .getJakartaJsonBFormatMapperOrNull ();
864
- }
852
+ final FormatMapper jsonJacksonFormatMapper = getJsonJacksonFormatMapperOrNull ();
853
+ return jsonJacksonFormatMapper != null ? jsonJacksonFormatMapper : getJakartaJsonBFormatMapperOrNull ();
865
854
}
866
855
);
867
856
}
@@ -871,11 +860,8 @@ private static FormatMapper determineXmlFormatMapper(Object setting, StrategySel
871
860
FormatMapper .class ,
872
861
setting ,
873
862
(Callable <FormatMapper >) () -> {
874
- final FormatMapper jacksonFormatMapper = JacksonIntegration .getXMLJacksonFormatMapperOrNull ();
875
- if (jacksonFormatMapper != null ) {
876
- return jacksonFormatMapper ;
877
- }
878
- return new JaxbXmlFormatMapper ();
863
+ final FormatMapper jacksonFormatMapper = getXMLJacksonFormatMapperOrNull ();
864
+ return jacksonFormatMapper != null ? jacksonFormatMapper : new JaxbXmlFormatMapper ();
879
865
}
880
866
);
881
867
}
@@ -1393,21 +1379,22 @@ public void enableStatisticsSupport(boolean enabled) {
1393
1379
}
1394
1380
1395
1381
public void addSessionFactoryObservers (SessionFactoryObserver ... observers ) {
1396
- Collections .addAll ( this . sessionFactoryObserverList , observers );
1382
+ Collections .addAll ( sessionFactoryObserverList , observers );
1397
1383
}
1398
1384
1399
1385
public void applyInterceptor (Interceptor interceptor ) {
1400
1386
this .interceptor = interceptor ;
1401
1387
}
1402
1388
1403
1389
public void applyStatelessInterceptor (Class <? extends Interceptor > statelessInterceptorClass ) {
1404
- this . applyStatelessInterceptorSupplier (
1390
+ applyStatelessInterceptorSupplier (
1405
1391
() -> {
1406
1392
try {
1407
1393
return statelessInterceptorClass .newInstance ();
1408
1394
}
1409
1395
catch (InstantiationException | IllegalAccessException e ) {
1410
- throw new HibernateException ( String .format ( "Could not supply stateless Interceptor of class %s" , statelessInterceptorClass .getName ()), e );
1396
+ throw new HibernateException ( "Could not supply stateless Interceptor of class '"
1397
+ + statelessInterceptorClass .getName () + "'" , e );
1411
1398
}
1412
1399
}
1413
1400
);
@@ -1563,10 +1550,10 @@ public void enableCommentsSupport(boolean enabled) {
1563
1550
}
1564
1551
1565
1552
public void applySqlFunction (String registrationName , SqmFunctionDescriptor sqlFunction ) {
1566
- if ( this . sqlFunctions == null ) {
1567
- this . sqlFunctions = new HashMap <>();
1553
+ if ( sqlFunctions == null ) {
1554
+ sqlFunctions = new HashMap <>();
1568
1555
}
1569
- this . sqlFunctions .put ( registrationName , sqlFunction );
1556
+ sqlFunctions .put ( registrationName , sqlFunction );
1570
1557
}
1571
1558
1572
1559
public void allowOutOfTransactionUpdateOperations (boolean allow ) {
@@ -1582,11 +1569,12 @@ public void enableJpaQueryCompliance(boolean enabled) {
1582
1569
}
1583
1570
1584
1571
private MutableJpaCompliance mutableJpaCompliance () {
1585
- if ( !(this .jpaCompliance instanceof MutableJpaCompliance ) ) {
1572
+ if ( jpaCompliance instanceof MutableJpaCompliance mutableJpaCompliance ) {
1573
+ return mutableJpaCompliance ;
1574
+ }
1575
+ else {
1586
1576
throw new IllegalStateException ( "JpaCompliance is no longer mutable" );
1587
1577
}
1588
-
1589
- return (MutableJpaCompliance ) this .jpaCompliance ;
1590
1578
}
1591
1579
1592
1580
public void enableJpaTransactionCompliance (boolean enabled ) {
@@ -1627,10 +1615,9 @@ public void disableJtaTransactionAccess() {
1627
1615
}
1628
1616
1629
1617
public SessionFactoryOptions buildOptions () {
1630
- if ( this . jpaCompliance instanceof MutableJpaCompliance ) {
1631
- this . jpaCompliance = mutableJpaCompliance ().immutableCopy ();
1618
+ if ( jpaCompliance instanceof MutableJpaCompliance ) {
1619
+ jpaCompliance = mutableJpaCompliance ().immutableCopy ();
1632
1620
}
1633
-
1634
1621
return this ;
1635
1622
}
1636
1623
}
0 commit comments