Fetching association and using implicit path in condition fails
Description
Activity
Show:
Sven Strickroth December 8, 2022 at 10:17 AM
THis is probably the same issue as https://hibernate.atlassian.net/browse/HHH-15821, but in a following order clause the PK is not used any more with Hibernate >= 6.
Thomas Heigl October 31, 2022 at 4:58 PM
My test passes with your fix!
Christian Beikov October 31, 2022 at 4:37 PM
Hi Thomas! Can you try the fix from https://github.com/hibernate/hibernate-orm/pull/5479 and tell me if that works for you?
Thomas Heigl October 31, 2022 at 4:33 PM
This is probably the same issue as https://hibernate.atlassian.net/browse/HHH-15645
Fixed
Assignee
Reporter
Christian Beikov
Christian BeikovComponents
Fix versions
Affects versions
Priority
Created October 31, 2022 at 3:05 PM
Updated December 8, 2022 at 10:17 AM
Resolved November 2, 2022 at 10:54 AM
A query like the following
CriteriaQuery<Customer> criteria = builder.createQuery( Customer.class ); Root<Customer> customerRoot = criteria.from( Customer.class ); customerRoot.fetch( "home", JoinType.INNER ); criteria.where( customerRoot.get( "home" ).in( em.getReference( Address.class, "abc" ) ) );
fails because the FK key part is used instead of the target part for the association implicit path. It fails with:
Caused by: org.hibernate.sql.ast.tree.from.UnknownTableReferenceException: Unable to determine TableReference (`home`) for `Customer(375683657376).home` at org.hibernate.sql.ast.tree.from.LazyTableGroup.resolveTableReference(LazyTableGroup.java:256) at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:318) at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:232) at org.hibernate.query.sqm.sql.internal.EntityValuedPathInterpretation.from(EntityValuedPathInterpretation.java:128) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.lambda$visitEntityValuedPath$57(BaseSqmToSqlAstConverter.java:3833) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3143) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.prepareReusablePath(BaseSqmToSqlAstConverter.java:3105) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitEntityValuedPath(BaseSqmToSqlAstConverter.java:3833) at org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter.visitEntityValuedPath(BaseSqmToSqlAstConverter.java:414) at org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath.accept(SqmEntityValuedSimplePath.java:62)