Criteria EXISTS Subquery referring the Root of the Query of which it is a Subquery causes "Error interpreting query [SqmRoot not yet resolved to TableGroup]"

Description

Simple criteriaBuilder.exists(subQuery) conditions don’t work anymore under 6.1.2, while they worked under 5.6.10, the following exception is thrown: org.hibernate.query.sqm.InterpretationException: Error interpreting query [SqmRoot not yet resolved to TableGroup]; this may indicate a semantic (user query) problem or a bug in the parser [SqmRoot not yet resolved to TableGroup].

I attached a simple example project, extract it and run mvnw test. It is a minimal Spring Boot project that recreates the data model from Vlad’s blog post and issues his example queries in both JPQL and Criteria variants. The JPQL variant succeeds, the Criteria variant throws the aforementioned exception.

 

I encountered this issue while trying to migrate our applications to Hibernate 6, where we make tons of criteria subqueries.

Attachments

1

Activity

Show:
Fixed

Details

Assignee

Reporter

Worked in

Components

Fix versions

Affects versions

Priority

Created September 2, 2022 at 9:04 PM
Updated July 20, 2023 at 8:27 AM
Resolved September 8, 2022 at 11:20 AM