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