Marco Belladelli (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=637b480...
) *commented* on HHH-16865 (
https://hibernate.atlassian.net/browse/HHH-16865?atlOrigin=eyJpIjoiYWM4OW...
)
Re: Multiselect CriteriaQuery fails with "Could not locate TableGroup" (
https://hibernate.atlassian.net/browse/HHH-16865?atlOrigin=eyJpIjoiYWM4OW...
)
The way you’re constructing this multiselect Criteria Query is wrong - you are creating a
query to get the Root , than creating another query and re-using that root object there
without specifying a from. I'm afraid this used to work in Hibernate 5 by chance, but
even JPA's AbstractQuery#getRoots() javadoc (
https://jakarta.ee/specifications/persistence/3.1/apidocs/jakarta.persist...
) says:
… Modifications to the set do not affect the query.
The correct way to do this in your reproducer would be something like this:
CriteriaQuery<TestDto> queryMulti = criteriaBuilder.createQuery(TestDto.class);
Root<TestTbl> root = queryMulti.from(TestTbl.class);
CriteriaQuery<?> multiselect = queryMulti.multiselect(root.get(TestTbl_.id));
Closing this issue as the behavior in Hibernate 6 is consistent with the spec.
If you have any additional doubt or request feel free to leave a comment.
(
https://hibernate.atlassian.net/browse/HHH-16865#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16865#add-comment?atlOrigin=ey...
)
Get Jira notifications on your phone! Download the Jira Cloud app for Android (
https://play.google.com/store/apps/details?id=com.atlassian.android.jira....
) or iOS (
https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=Em...
) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100228- sha1:e911e2c )