-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Specification.not()
fails with NullPointerException
when other Specification
returns null
#3849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In the current semantics, if specification.toPredicate() returns null, it means no condition—which logically translates to an Expression true. Thus, in the not() method, we can return criteriaBuilder.disjunction() to represent false, because: This ensures that negating a null predicate (implicitly true) correctly results in false instead of throwing an NPE. |
Care to submit a pull request? |
Specification.not()
fails with NullPointerException
when other Specification
returns null
I'll try to submit a PR over the weekend |
When toPredicate() returns null, Specification.not() now returns builder.disjunction() instead of builder.not(null). This change ensures proper handling of null predicates in negated specifications. spring-projects#3849
spring-projects#3849 When toPredicate() returns null, Specification.not() now returns builder.disjunction() instead of builder.not(null). This change ensures proper handling of null predicates in negated specifications.
spring-projects#3849 When toPredicate() returns null, Specification.not() now returns builder.disjunction() instead of builder.not(null). This change ensures proper handling of null predicates in negated specifications. Signed-off-by: SWQXDBA <[email protected]>
Cannot invoke "org.hibernate.query.sqm.tree.expression.SqmExpression.getExpressible()" because "booleanExpression" is null\njava.lang.NullPointerException: Cannot invoke "org.hibernate.query.sqm.tree.expression.SqmExpression.getExpressible()" because "booleanExpression" is null
at org.hibernate.query.sqm.tree.predicate.SqmBooleanExpressionPredicate.(SqmBooleanExpressionPredicate.java:38)
at org.hibernate.query.sqm.tree.predicate.SqmBooleanExpressionPredicate.(SqmBooleanExpressionPredicate.java:31)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.wrap(SqmCriteriaNodeBuilder.java:497)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.not(SqmCriteriaNodeBuilder.java:2088)
at org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder.not(SqmCriteriaNodeBuilder.java:192)
at org.springframework.data.jpa.domain.Specification.lambda$1(Specification.java:58)
at org.springframework.data.jpa.domain.SpecificationComposition.toPredicate(SpecificationComposition.java:62)
at org.springframework.data.jpa.domain.SpecificationComposition.lambda$0(SpecificationComposition.java:49)
at org.springframework.data.jpa.domain.SpecificationComposition.toPredicate(SpecificationComposition.java:62)
The text was updated successfully, but these errors were encountered: