Skip to content

AbstractQueryCreator methods should be nullable and handle nulls #3317

Closed
@SledgeHammer01

Description

@SledgeHammer01

In this method here:

https://github.com/spring-projects/spring-data-commons/blob/main/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java#L106-L129

Shouldn't the create() method used here (as well as the and() or or() methods) allow and consider null returns?

https://github.com/spring-projects/spring-data-commons/blob/main/src/main/java/org/springframework/data/repository/query/parser/AbstractQueryCreator.java#L119

Consider the case in a custom query creator where I am processing keywords, but for a specific keyword, based on some logic, I DO NOT want to add a predicate. So, from PredicateBuilder::build(), I would want to return null (which works if I don't have any additional predicates), but if I did, that would blow up on the and() and or() calls.

The only thing I can do now is use CriteriaBuilder::conjunction() but that adds a where 1=1 clause.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions