[JIRA] (HHH-15731) Multi-level Derived Tables fail with Unsupported path source: org.hibernate.query.derived.AnonymousTupleSqmPathSource
by Vlad Mihalcea (JIRA)
Vlad Mihalcea ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiNzlmNDllMDRj... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-15731?atlOrigin=eyJpIjoiNzlmND... ) HHH-15731 ( https://hibernate.atlassian.net/browse/HHH-15731?atlOrigin=eyJpIjoiNzlmND... ) Multi-level Derived Tables fail with Unsupported path source: org.hibernate.query.derived.AnonymousTupleSqmPathSource ( https://hibernate.atlassian.net/browse/HHH-15731?atlOrigin=eyJpIjoiNzlmND... )
Issue Type: Bug Affects Versions: 6.1.5 Assignee: Unassigned Components: hibernate-core Created: 17/Nov/2022 01:25 AM Priority: Major Reporter: Vlad Mihalcea ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
The following derived table works fine:
List<Tuple> tuples = session.createQuery("""
SELECT
post_id AS post_id,
post_title AS post_title,
comment_id AS comment_id,
comment_review AS comment_review,
DENSE_RANK() OVER (ORDER BY p_pc.comment_count DESC) AS ranking
FROM (
SELECT
p.id AS post_id,
p.title AS post_title,
http://pc.id AS comment_id,
pc.review AS comment_review,
COUNT(p.id) OVER(PARTITION BY p.id) AS comment_count
FROM PostComment pc
JOIN pc.post p
WHERE p.title LIKE :title
) p_pc
ORDER BY post_id, comment_id
""", Tuple.class)
.setParameter("title", "SQL%")
.getResultList();
But the following one fails:
tuples = session.createQuery("""
SELECT
post_id AS pid,
post_title AS pt,
comment_id AS cid,
comment_review AS cr
FROM (
SELECT
post_id AS post_id,
post_title AS post_title,
comment_id AS comment_id,
comment_review AS comment_review,
DENSE_RANK() OVER (ORDER BY p_pc.comment_count DESC) AS ranking
FROM (
SELECT
p.id AS post_id,
p.title AS post_title,
pc.id AS comment_id,
pc.review AS comment_review,
COUNT(p.id) OVER(PARTITION BY p.id) AS comment_count
FROM PostComment pc
JOIN pc.post p
WHERE p.title LIKE :title
) p_pc
) p_pc_r
WHERE ranking <= :ranking
ORDER BY post_id, comment_id
""", Tuple.class)
.setParameter("title", "SQL%")
.setParameter("ranking", 2)
.getResultList();
Because of this:
Caused by: java.lang.UnsupportedOperationException: Unsupported path source: org.hibernate.query.derived.AnonymousTupleSqmPathSource@34e091ff
at org.hibernate.query.derived.AnonymousTupleSqmPathSource.createSqmPath(AnonymousTupleSqmPathSource.java:106)
at org.hibernate.query.sqm.tree.domain.AbstractSqmPath.resolvePath(AbstractSqmPath.java:173)
at org.hibernate.query.sqm.tree.domain.AbstractSqmPath.get(AbstractSqmPath.java:162)
at org.hibernate.query.hql.internal.BasicDotIdentifierConsumer$BaseLocalSequencePart.resolvePathPart(BasicDotIdentifierConsumer.java:151)
at org.hibernate.query.hql.internal.BasicDotIdentifierConsumer.consumeIdentifier(BasicDotIdentifierConsumer.java:91)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimplePath(SemanticQueryBuilder.java:4797)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitIndexedPathAccessFragment(SemanticQueryBuilder.java:4755)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGeneralPathFragment(SemanticQueryBuilder.java:4724)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitGeneralPathExpression(SemanticQueryBuilder.java:1423)
at org.hibernate.grammars.hql.HqlParser$GeneralPathExpressionContext.accept(HqlParser.java:6963)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitBarePrimaryExpression(HqlParserBaseVisitor.java:671)
at org.hibernate.grammars.hql.HqlParser$BarePrimaryExpressionContext.accept(HqlParser.java:6437)
at org.antlr.v4.runtime.tree.AbstractParseTreeVisitor.visitChildren(AbstractParseTreeVisitor.java:46)
at org.hibernate.grammars.hql.HqlParserBaseVisitor.visitExpressionOrPredicate(HqlParserBaseVisitor.java:811)
at org.hibernate.grammars.hql.HqlParser$ExpressionOrPredicateContext.accept(HqlParser.java:7186)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectableNode(SemanticQueryBuilder.java:978)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelection(SemanticQueryBuilder.java:952)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectClause(SemanticQueryBuilder.java:935)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuery(SemanticQueryBuilder.java:837)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:629)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitQuerySpecExpression(SemanticQueryBuilder.java:243)
at org.hibernate.grammars.hql.HqlParser$QuerySpecExpressionContext.accept(HqlParser.java:1218)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:623)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSimpleQueryGroup(SemanticQueryBuilder.java:243)
at org.hibernate.grammars.hql.HqlParser$SimpleQueryGroupContext.accept(HqlParser.java:1131)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitSelectStatement(SemanticQueryBuilder.java:399)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.visitStatement(SemanticQueryBuilder.java:358)
at org.hibernate.query.hql.internal.SemanticQueryBuilder.buildSemanticModel(SemanticQueryBuilder.java:285)
at org.hibernate.query.hql.internal.StandardHqlTranslator.translate(StandardHqlTranslator.java:81)
... 21 more
( https://hibernate.atlassian.net/browse/HHH-15731#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-15731#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=EmailN... ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100210- sha1:9b34d7c )
1 year, 11 months