karthik ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6331f78... ) *created* an issue
Hibernate Validator ( https://hibernate.atlassian.net/browse/HV?atlOrigin=eyJpIjoiYTQ4Yzk2NmU3N... ) / Bug ( https://hibernate.atlassian.net/browse/HV-1940?atlOrigin=eyJpIjoiYTQ4Yzk2... ) HV-1940 ( https://hibernate.atlassian.net/browse/HV-1940?atlOrigin=eyJpIjoiYTQ4Yzk2... ) Error when using @Query with EmbeddedId after upgrading to Spring Boot 3.0.4 ( https://hibernate.atlassian.net/browse/HV-1940?atlOrigin=eyJpIjoiYTQ4Yzk2... )
Issue Type: Bug Affects Versions: 6.1.7.Final Assignee: Unassigned Components: engine, translations Created: 07/Mar/2023 19:33 PM Environment: Java 17
hibernate-core-6.1.7.Final.jar
spring-boot-starter-parent - 3.0.4 Priority: Major Reporter: karthik ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=6331f78... )
Error when using @Query with EmbeddedId after upgrading to Spring Boot 3.0. ( https://stackoverflow.com/questions/75151335/error-when-using-query-with-... ) 4
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
org.hibernate.query.sqm.InterpretationException occurs when the query uses embeddedId in the subquery section with a relation between the outer and the inner query
Code Sample:
public interface SampleRepo extends BaseJpaRepo<AppUser, UUID> {
public static final String COUNT_QUERY = "SELECT COUNT(*) FROM";
//No EmbeddedId - works fine
@Query(value = COUNT_QUERY + " QueryEntity u1, Visualization u2"//
+ " WHERE u1.id IN (SELECT id from ModelEntity WHERE id=u2.queryId)"//
) //
public Long deleteCount1();
//EmbeddedId Simple Query - works fine
@Query(value = "SELECT COUNT(*) from QueryUser WHERE id.queryId=?1 AND id.userId=?2") //
public Long deleteCount2(Integer id, UUID loggedInUserId);
//EmbeddedId Simple Query in the SubQuery section - works fine
@Query(value = COUNT_QUERY + " QueryEntity u1, Visualization u2"//
+ " WHERE u1.id IN (SELECT id.queryId from QueryUser WHERE id.userId=?1)"//
) //
public Long deleteCount3(UUID loggedInUserId);
//EmbeddedId Query in the SubQuery section with relation between the outer and the inner query - Breaks
@Query(value = COUNT_QUERY + " QueryEntity u1, Visualization u2"//
+ " WHERE u1.id IN (SELECT id.queryId from QueryUser WHERE id.queryId = u2.queryId AND id.userId=?1)"//
) //
public Long deleteCount4(UUID loggedInUserId);}
Exception:
org.hibernate.query.sqm.InterpretationException: Error interpreting query [SELECT COUNT(*) FROM QueryEntity u1, Visualization u2 WHERE u1.id IN (SELECT id.queryId from QueryUser WHERE id.queryId = u2.queryId AND id.userId=?1)] ; this may indicate a semantic (user query) problem or a bug in the parser [SELECT COUNT(*) FROM QueryEntity u1, Visualization u2 WHERE u1.id IN (SELECT id.queryId from QueryUser WHERE id.queryId = u2.queryId AND id.userId=?1)] \n\tat org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:97)\n\tat org.hibernate.internal.AbstractSharedSessionContract.lambda$createQuery$2(AbstractSharedSessionContract.java:747)\n\tat org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.createHqlInterpretation(QueryInterpretationCacheStandardImpl.java:141)\n\tat org.hibernate.query.internal.QueryInterpretationCacheStandardImpl.resolveHqlInterpretation(QueryInterpretationCacheStandardImpl.java:128)\n\tat org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:744)\n\t... 47 common frames omitted\nCaused by: java.lang.IllegalStateException: Multiple from-elements expose unqualified attribute : id\n\tat org.hibernate.query.hql.internal.SqmPathRegistryImpl.findFromExposing(SqmPathRegistryImpl.java:192)\n\tat org.hibernate.query.hql.internal.BasicDotIdentifierConsumer$BaseLocalSequencePart.resolvePathPart(BasicDotIdentifierConsumer.java:146)\n\tat org.hibernate.query.hql.internal.BasicDotIdentifierConsumer.consumeIdentifier
More details can be found at
https://stackoverflow.com/questions/75151335/error-when-using-query-with-... ( https://stackoverflow.com/questions/75151335/error-when-using-query-with-... )
( https://hibernate.atlassian.net/browse/HV-1940#add-comment?atlOrigin=eyJp... ) Add Comment ( https://hibernate.atlassian.net/browse/HV-1940#add-comment?atlOrigin=eyJp... )
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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100217- sha1:45db922 )