SemanticQueryBuilder#visitPathExpression() cannot cast DomainPathPart to SqmExpression

This commit is contained in:
Andrea Boriero 2021-03-10 14:39:34 +01:00 committed by Christian Beikov
parent 15b52460f3
commit 60c4fbe099
3 changed files with 21 additions and 1 deletions

View File

@ -29,6 +29,10 @@ public class DomainPathPart implements SemanticPathPart {
assert currentPath != null;
}
SqmExpression<?> getSqmExpression() {
return currentPath;
}
@Override
public SemanticPathPart resolvePathPart(
String name,

View File

@ -1158,7 +1158,12 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
@Override
public SqmExpression<?> visitPathExpression(HqlParser.PathExpressionContext ctx) {
return (SqmExpression<?>) ctx.path().accept( this );
final HqlParser.PathContext path = ctx.path();
final Object accept = path.accept( this );
if ( accept instanceof DomainPathPart ) {
return ( (DomainPathPart) accept ).getSqmExpression();
}
return (SqmExpression<?>) accept;
}
@Override

View File

@ -61,6 +61,17 @@ public class SubQueryImplicitJoinReferenceTest {
} );
}
@Test
public void performHqlIsNullTest(SessionFactoryScope scope) {
// Now simulate running an audit query
scope.inSession( session -> {
session.createQuery( "select e__ FROM TheEntity e__ "
+ "WHERE e__.originalId.rev.id = (select max(e2__.originalId.rev.id) FROM "
+ "TheEntity e2__ WHERE " +
"e2__.originalId.rev is null)" ).list();
} );
}
@Test
public void performHqlTest2(SessionFactoryScope scope) {
// Now simulate running an audit query