Skip to content

Commit 186d9f5

Browse files
bezzang-devchristophstrobl
authored andcommitted
Render NEGATING_SIMPLE_PROPERTY as IS NOT NULL when argument value is null.
When a query method uses NEGATING_SIMPLE_PROPERTY and the argument is null, the generated query now uses `IS NOT NULL` instead of `<>`. This ensures consistent behavior when handling null values across queries. Closes: #3675 Original Pull Request: #3681
1 parent 6255a0c commit 186d9f5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryCreator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* @author Moritz Becker
5757
* @author Andrey Kovalev
5858
* @author Greg Turnquist
59+
* @author Jinmyeong Kim
5960
*/
6061
public class JpaQueryCreator extends AbstractQueryCreator<CriteriaQuery<? extends Object>, Predicate> {
6162

@@ -311,8 +312,10 @@ public Predicate build() {
311312
return expression.isIsNullParameter() ? path.isNull()
312313
: builder.equal(upperIfIgnoreCase(path), upperIfIgnoreCase(expression.getExpression()));
313314
case NEGATING_SIMPLE_PROPERTY:
314-
return builder.notEqual(upperIfIgnoreCase(getTypedPath(root, part)),
315-
upperIfIgnoreCase(provider.next(part).getExpression()));
315+
ParameterMetadata<Object> negatedExpression = provider.next(part);
316+
Expression<Object> negatedPath = getTypedPath(root, part);
317+
return negatedExpression.isIsNullParameter() ? negatedPath.isNotNull()
318+
: builder.notEqual(upperIfIgnoreCase(negatedPath), upperIfIgnoreCase(negatedExpression.getExpression()));
316319
case IS_EMPTY:
317320
case IS_NOT_EMPTY:
318321

0 commit comments

Comments
 (0)