Daniel Novo (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ae986b...
) *created* an issue
Hibernate ORM (
https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiZTFmZDA5MGM3...
) / Bug (
https://hibernate.atlassian.net/browse/HHH-16622?atlOrigin=eyJpIjoiZTFmZD...
) HHH-16622 (
https://hibernate.atlassian.net/browse/HHH-16622?atlOrigin=eyJpIjoiZTFmZD...
) Criteria API - Already registered a copy (
https://hibernate.atlassian.net/browse/HHH-16622?atlOrigin=eyJpIjoiZTFmZD...
)
Issue Type: Bug Affects Versions: 6.2.1 Assignee: Unassigned Components: hibernate-core
Created: 17/May/2023 03:44 AM Priority: Major Reporter: Daniel Novo (
https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5ae986b...
)
With Criteria API, reusing Predicates with subqueries we are getting this error:
Already registered a copy: org.hibernate.query.sqm.tree.select.SqmSubQuery@4416e18d
Without subqueries, we are getting other error
org.hibernate.sql.ast.SqlTreeCreationException: Could not locate TableGroup
Sample:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<MyEntity> cq = cb.createQuery(MyEntity.class);
Root<MyEntity> root = cq.from(MyEntity.class);
List<Predicate> predicates = getPredicates(cb,cq, root, "1");
cq.select(root).where(predicates.toArray(Predicate[]::new));
TypedQuery<MyEntity> q = entityManager.createQuery(cq);
long count = count(entityManager, predicates);
Same code in hibernate 5 works fine.
(
https://hibernate.atlassian.net/browse/HHH-16622#add-comment?atlOrigin=ey...
) Add Comment (
https://hibernate.atlassian.net/browse/HHH-16622#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#100225- sha1:11e4e77 )