criteriaBuilder.isEmpty used within criteriaBuilder.construct throws an exception

Description

When calling criteriaBuilder.isEmpty within criteriaBuilder.construct an exception is thrown:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 org.springframework.dao.InvalidDataAccessApiUsageException: Unexpected AST: org.hibernate.hql.internal.ast.tree.SqlNode \-[NOT] SqlNode: 'not' \-[EXISTS] UnaryLogicOperatorNode: 'exists' \-[SELECT] QueryNode: 'SELECT' querySpaces (child,toy) +-[SELECT_CLAUSE] SelectClause: '{derived select clause}' | \-[SELECT_EXPR] SelectExpressionImpl: 'toys1_.id' {ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=com.example.models.Child.toys,tableName=toy,tableAlias=toys1_,origin=child child0_,columns={child0_.id ,className=com.example.models.Toy}}} +-[FROM] FromClause: 'from' FromClause{level=2, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[toys1_], fromElementsByPath=[generatedAlias0.toys], collectionJoinFromElementsByPath=[], impliedElements=[]} | \-[FROM_FRAGMENT] ImpliedFromElement: 'toy toys1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=com.example.models.Child.toys,tableName=toy,tableAlias=toys1_,origin=child child0_,columns={child0_.id ,className=com.example.models.Toy}} \-[WHERE] SqlNode: 'WHERE' \-[THETA_JOINS] SqlNode: '{theta joins}' \-[SQL_TOKEN] SqlFragment: 'child0_.id=toys1_.child_id' ; nested exception is java.lang.IllegalStateException: Unexpected AST: org.hibernate.hql.internal.ast.tree.SqlNode \-[NOT] SqlNode: 'not' \-[EXISTS] UnaryLogicOperatorNode: 'exists' \-[SELECT] QueryNode: 'SELECT' querySpaces (child,toy) +-[SELECT_CLAUSE] SelectClause: '{derived select clause}' | \-[SELECT_EXPR] SelectExpressionImpl: 'toys1_.id' {ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=com.example.models.Child.toys,tableName=toy,tableAlias=toys1_,origin=child child0_,columns={child0_.id ,className=com.example.models.Toy}}} +-[FROM] FromClause: 'from' FromClause{level=2, fromElementCounter=1, fromElements=1, fromElementByClassAlias=[], fromElementByTableAlias=[toys1_], fromElementsByPath=[generatedAlias0.toys], collectionJoinFromElementsByPath=[], impliedElements=[]} | \-[FROM_FRAGMENT] ImpliedFromElement: 'toy toys1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=com.example.models.Child.toys,tableName=toy,tableAlias=toys1_,origin=child child0_,columns={child0_.id ,className=com.example.models.Toy}} \-[WHERE] SqlNode: 'WHERE' \-[THETA_JOINS] SqlNode: '{theta joins}' \-[SQL_TOKEN] SqlFragment: 'child0_.id=toys1_.child_id'

When

1 criteriaBuilder.isNotEmpty

is used instead of

1 criteriaBuilder.isEmpty

everything works fine.

I attach a test case.
To run it just unzip and run "gradlew test" on Windows or "./gradlew test" on Linux

Environment

None

Status

Assignee

Unassigned

Reporter

Jarek

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Priority

Major
Configure