@@ -108,27 +108,26 @@ public abstract class QueryUtils {
108
108
private static final String SIMPLE_COUNT_VALUE = "$2" ;
109
109
private static final String COMPLEX_COUNT_VALUE = "$3 $6" ;
110
110
private static final String COMPLEX_COUNT_LAST_VALUE = "$6" ;
111
- private static final Pattern ORDER_BY_PART = Pattern . compile ("(?iu)\\ s+order\\ s+by\\ s+.*" , CASE_INSENSITIVE | DOTALL );
111
+ private static final Pattern ORDER_BY_PART = compile ("(?iu)\\ s+order\\ s+by\\ s+.*" , CASE_INSENSITIVE | DOTALL );
112
112
113
113
private static final Pattern ALIAS_MATCH ;
114
114
private static final Pattern COUNT_MATCH ;
115
- private static final Pattern STARTS_WITH_PAREN = Pattern . compile ("^\\ s*\\ (" );
116
- private static final Pattern PARENS_TO_REMOVE = Pattern . compile ("(\\ (.*\\ bfrom\\ b[^)]+\\ ))" ,
115
+ private static final Pattern STARTS_WITH_PAREN = compile ("^\\ s*\\ (" );
116
+ private static final Pattern PARENS_TO_REMOVE = compile ("(\\ (.*\\ bfrom\\ b[^)]+\\ ))" ,
117
117
CASE_INSENSITIVE | DOTALL | MULTILINE );
118
- private static final Pattern PROJECTION_CLAUSE = Pattern .compile ("select\\ s+(?:distinct\\ s+)?(.+)\\ s+from" ,
119
- Pattern .CASE_INSENSITIVE );
118
+ private static final Pattern PROJECTION_CLAUSE = compile ("select\\ s+(?:distinct\\ s+)?(.+)\\ s+from" , CASE_INSENSITIVE );
120
119
121
- private static final Pattern NO_DIGITS = Pattern . compile ("\\ D+" );
120
+ private static final Pattern NO_DIGITS = compile ("\\ D+" );
122
121
123
122
private static final String JOIN = "join\\ s+(fetch\\ s+)?" + IDENTIFIER + "\\ s+(as\\ s+)?" + IDENTIFIER_GROUP ;
124
- private static final Pattern JOIN_PATTERN = Pattern . compile (JOIN , Pattern . CASE_INSENSITIVE );
123
+ private static final Pattern JOIN_PATTERN = compile (JOIN , CASE_INSENSITIVE );
125
124
126
125
private static final String EQUALS_CONDITION_STRING = "%s.%s = :%s" ;
127
- private static final Pattern ORDER_BY = Pattern . compile ("(order\\ s+by\\ s+)" , CASE_INSENSITIVE );
128
- private static final Pattern ORDER_BY_IN_WINDOW_OR_SUBSELECT = Pattern
129
- . compile ( " \\ ([ \\ s \\ S]*order \\ s+by \\ s[ \\ s \\ S]* \\ )" , CASE_INSENSITIVE );
126
+ private static final Pattern ORDER_BY = compile ("(order\\ s+by\\ s+)" , CASE_INSENSITIVE );
127
+ private static final Pattern ORDER_BY_IN_WINDOW_OR_SUBSELECT = compile ( " \\ ([ \\ s \\ S]*order \\ s+by \\ s[ \\ s \\ S]* \\ )" ,
128
+ CASE_INSENSITIVE );
130
129
131
- private static final Pattern NAMED_PARAMETER = Pattern . compile (COLON_NO_DOUBLE_COLON + IDENTIFIER + "|#" + IDENTIFIER ,
130
+ private static final Pattern NAMED_PARAMETER = compile (COLON_NO_DOUBLE_COLON + IDENTIFIER + "|#" + IDENTIFIER ,
132
131
CASE_INSENSITIVE );
133
132
134
133
private static final Pattern CONSTRUCTOR_EXPRESSION ;
@@ -139,7 +138,7 @@ public abstract class QueryUtils {
139
138
private static final int VARIABLE_NAME_GROUP_INDEX = 4 ;
140
139
private static final int COMPLEX_COUNT_FIRST_INDEX = 3 ;
141
140
142
- private static final Pattern PUNCTATION_PATTERN = Pattern . compile (".*((?![._])[\\ p{Punct}|\\ s])" );
141
+ private static final Pattern PUNCTATION_PATTERN = compile (".*((?![._])[\\ p{Punct}|\\ s])" );
143
142
private static final Pattern FUNCTION_PATTERN ;
144
143
private static final Pattern FIELD_ALIAS_PATTERN ;
145
144
@@ -431,13 +430,14 @@ static Set<String> getFunctionAliases(String query) {
431
430
}
432
431
433
432
private static String toJpaDirection (Order order ) {
433
+
434
434
String direction = order .getDirection ().name ().toLowerCase (Locale .US );
435
- if ( order . getNullHandling () == Sort . NullHandling . NULLS_FIRST ) {
436
- direction += " nulls first" ;
437
- } else if ( order . getNullHandling () == Sort . NullHandling . NULLS_LAST ) {
438
- direction += " nulls last " ;
439
- }
440
- return direction ;
435
+
436
+ return switch ( order . getNullHandling ()) {
437
+ case NATIVE -> direction ;
438
+ case NULLS_FIRST -> direction + " nulls first " ;
439
+ case NULLS_LAST -> direction + " nulls last" ;
440
+ } ;
441
441
}
442
442
443
443
/**
@@ -677,7 +677,7 @@ public static List<jakarta.persistence.criteria.Order> toOrders(Sort sort, From<
677
677
678
678
List <jakarta .persistence .criteria .Order > orders = new ArrayList <>();
679
679
680
- for (org . springframework . data . domain . Sort . Order order : sort ) {
680
+ for (Order order : sort ) {
681
681
orders .add (toJpaOrder (order , from , cb ));
682
682
}
683
683
@@ -848,7 +848,7 @@ static boolean requiresOuterJoin(From<?, ?> from, PropertyPath property, boolean
848
848
// if this path is an optional one to one attribute navigated from the not owning side we also need an
849
849
// explicit outer join to avoid https://hibernate.atlassian.net/browse/HHH-12712
850
850
// and https://github.com/eclipse-ee4j/jpa-api/issues/170
851
- boolean isInverseOptionalOneToOne = PersistentAttributeType . ONE_TO_ONE == attribute .getPersistentAttributeType ()
851
+ boolean isInverseOptionalOneToOne = ONE_TO_ONE == attribute .getPersistentAttributeType ()
852
852
&& StringUtils .hasText (getAnnotationProperty (attribute , "mappedBy" , "" ));
853
853
854
854
boolean isLeafProperty = !property .hasNext ();
0 commit comments