@@ -601,6 +601,12 @@ private static boolean disallowBatchUpdates(Dialect dialect, ExtractedDatabaseMe
601601 return dialectAnswer != null ? !dialectAnswer : !meta .supportsBatchUpdates ();
602602 }
603603
604+ private static boolean hasStrategyConstructorSignature (Class <?>[] parameterTypes ) {
605+ return parameterTypes .length == 2
606+ && parameterTypes [0 ] == EntityMappingType .class
607+ && parameterTypes [1 ] == RuntimeModelCreationContext .class ;
608+ }
609+
604610 @ SuppressWarnings ("unchecked" )
605611 private SqmMultiTableMutationStrategy resolveSqmMutationStrategy (
606612 String strategyName ,
@@ -631,9 +637,7 @@ private SqmMultiTableMutationStrategy resolveSqmMutationStrategy(
631637 else if ( parameterTypes .length == 0 ) {
632638 emptyConstructor = constructor ;
633639 }
634- else if ( parameterTypes .length == 2
635- && parameterTypes [0 ] == EntityMappingType .class
636- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
640+ else if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
637641 entityBasedConstructor = (Constructor <SqmMultiTableMutationStrategy >) declaredConstructor ;
638642 }
639643 }
@@ -651,13 +655,12 @@ else if ( emptyConstructor != null ) {
651655 }
652656 catch (Exception e ) {
653657 throw new StrategySelectionException (
654- "Could not instantiate named strategy class [" +
655- strategyClass .getName () + "]" ,
658+ "Could not instantiate named strategy class [" + strategyClass .getName () + "]" ,
656659 e
657660 );
658661 }
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" );
661664 }
662665 else {
663666 return null ;
@@ -675,9 +678,7 @@ private Constructor<SqmMultiTableMutationStrategy> resolveSqmMutationStrategyCon
675678 strategySelector .selectStrategyImplementor ( SqmMultiTableMutationStrategy .class , strategyName );
676679 for ( var declaredConstructor : strategyClass .getDeclaredConstructors () ) {
677680 final var parameterTypes = declaredConstructor .getParameterTypes ();
678- if ( parameterTypes .length == 2
679- && parameterTypes [0 ] == EntityMappingType .class
680- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
681+ if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
681682 return (Constructor <SqmMultiTableMutationStrategy >) declaredConstructor ;
682683 }
683684 }
@@ -715,9 +716,7 @@ private SqmMultiTableInsertStrategy resolveSqmInsertStrategy(
715716 else if ( parameterTypes .length == 0 ) {
716717 emptyConstructor = constructor ;
717718 }
718- else if ( parameterTypes .length == 2
719- && parameterTypes [0 ] == EntityMappingType .class
720- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
719+ else if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
721720 entityBasedConstructor = (Constructor <SqmMultiTableInsertStrategy >) declaredConstructor ;
722721 }
723722 }
@@ -759,9 +758,7 @@ private Constructor<SqmMultiTableInsertStrategy> resolveSqmInsertStrategyConstru
759758 strategySelector .selectStrategyImplementor ( SqmMultiTableInsertStrategy .class , strategyName );
760759 for ( var declaredConstructor : strategyClass .getDeclaredConstructors () ) {
761760 final var parameterTypes = declaredConstructor .getParameterTypes ();
762- if ( parameterTypes .length == 2
763- && parameterTypes [0 ] == EntityMappingType .class
764- && parameterTypes [1 ] == RuntimeModelCreationContext .class ) {
761+ if ( hasStrategyConstructorSignature ( parameterTypes ) ) {
765762 return (Constructor <SqmMultiTableInsertStrategy >) declaredConstructor ;
766763 }
767764 }
@@ -997,7 +994,8 @@ public SqmMultiTableMutationStrategy resolveCustomSqmMultiTableMutationStrategy(
997994 }
998995 catch (Exception e ) {
999996 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 () ),
1001999 e
10021000 );
10031001 }
@@ -1013,7 +1011,8 @@ public SqmMultiTableInsertStrategy resolveCustomSqmMultiTableInsertStrategy(Enti
10131011 }
10141012 catch (Exception e ) {
10151013 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 () ),
10171016 e
10181017 );
10191018 }
0 commit comments