@@ -601,6 +601,12 @@ private static boolean disallowBatchUpdates(Dialect dialect, ExtractedDatabaseMe
601
601
return dialectAnswer != null ? !dialectAnswer : !meta .supportsBatchUpdates ();
602
602
}
603
603
604
+ private static boolean hasStrategyConstructorSignature (Class <?>[] parameterTypes ) {
605
+ return parameterTypes .length == 2
606
+ && parameterTypes [0 ] == EntityMappingType .class
607
+ && parameterTypes [1 ] == RuntimeModelCreationContext .class ;
608
+ }
609
+
604
610
@ SuppressWarnings ("unchecked" )
605
611
private SqmMultiTableMutationStrategy resolveSqmMutationStrategy (
606
612
String strategyName ,
@@ -631,9 +637,7 @@ private SqmMultiTableMutationStrategy resolveSqmMutationStrategy(
631
637
else if ( parameterTypes .length == 0 ) {
632
638
emptyConstructor = constructor ;
633
639
}
634
- else if ( parameterTypes .length == 2
635
- && parameterTypes [0 ] == EntityMappingType .class
636
- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
640
+ else if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
637
641
entityBasedConstructor = (Constructor <SqmMultiTableMutationStrategy >) declaredConstructor ;
638
642
}
639
643
}
@@ -651,13 +655,12 @@ else if ( emptyConstructor != null ) {
651
655
}
652
656
catch (Exception e ) {
653
657
throw new StrategySelectionException (
654
- "Could not instantiate named strategy class [" +
655
- strategyClass .getName () + "]" ,
658
+ "Could not instantiate named strategy class [" + strategyClass .getName () + "]" ,
656
659
e
657
660
);
658
661
}
659
- throw new IllegalArgumentException (
660
- "Cannot instantiate the class [" + strategyClass . getName () + "] because it does not have a constructor that accepts a dialect or an empty constructor" );
662
+ throw new IllegalArgumentException ( "Cannot instantiate the class [" + strategyClass . getName ()
663
+ + "] because it does not have a constructor that accepts a dialect or an empty constructor" );
661
664
}
662
665
else {
663
666
return null ;
@@ -675,9 +678,7 @@ private Constructor<SqmMultiTableMutationStrategy> resolveSqmMutationStrategyCon
675
678
strategySelector .selectStrategyImplementor ( SqmMultiTableMutationStrategy .class , strategyName );
676
679
for ( var declaredConstructor : strategyClass .getDeclaredConstructors () ) {
677
680
final var parameterTypes = declaredConstructor .getParameterTypes ();
678
- if ( parameterTypes .length == 2
679
- && parameterTypes [0 ] == EntityMappingType .class
680
- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
681
+ if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
681
682
return (Constructor <SqmMultiTableMutationStrategy >) declaredConstructor ;
682
683
}
683
684
}
@@ -715,9 +716,7 @@ private SqmMultiTableInsertStrategy resolveSqmInsertStrategy(
715
716
else if ( parameterTypes .length == 0 ) {
716
717
emptyConstructor = constructor ;
717
718
}
718
- else if ( parameterTypes .length == 2
719
- && parameterTypes [0 ] == EntityMappingType .class
720
- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
719
+ else if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
721
720
entityBasedConstructor = (Constructor <SqmMultiTableInsertStrategy >) declaredConstructor ;
722
721
}
723
722
}
@@ -759,9 +758,7 @@ private Constructor<SqmMultiTableInsertStrategy> resolveSqmInsertStrategyConstru
759
758
strategySelector .selectStrategyImplementor ( SqmMultiTableInsertStrategy .class , strategyName );
760
759
for ( var declaredConstructor : strategyClass .getDeclaredConstructors () ) {
761
760
final var parameterTypes = declaredConstructor .getParameterTypes ();
762
- if ( parameterTypes .length == 2
763
- && parameterTypes [0 ] == EntityMappingType .class
764
- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
761
+ if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
765
762
return (Constructor <SqmMultiTableInsertStrategy >) declaredConstructor ;
766
763
}
767
764
}
@@ -997,7 +994,8 @@ public SqmMultiTableMutationStrategy resolveCustomSqmMultiTableMutationStrategy(
997
994
}
998
995
catch (Exception e ) {
999
996
throw new StrategySelectionException (
1000
- String .format ( "Could not instantiate named strategy class [%s]" , sqmMultiTableMutationStrategyConstructor .getDeclaringClass ().getName () ),
997
+ String .format ( "Could not instantiate named strategy class [%s]" ,
998
+ sqmMultiTableMutationStrategyConstructor .getDeclaringClass ().getName () ),
1001
999
e
1002
1000
);
1003
1001
}
@@ -1013,7 +1011,8 @@ public SqmMultiTableInsertStrategy resolveCustomSqmMultiTableInsertStrategy(Enti
1013
1011
}
1014
1012
catch (Exception e ) {
1015
1013
throw new StrategySelectionException (
1016
- String .format ( "Could not instantiate named strategy class [%s]" , sqmMultiTableInsertStrategyConstructor .getDeclaringClass ().getName () ),
1014
+ String .format ( "Could not instantiate named strategy class [%s]" ,
1015
+ sqmMultiTableInsertStrategyConstructor .getDeclaringClass ().getName () ),
1017
1016
e
1018
1017
);
1019
1018
}
0 commit comments