TREAT in WHERE clause throws exception

Description

Hello,

I have two entities:

1 2 3 @Entity("product") public class Product { }

and

1 2 3 @Entity("variant_product") public class VariantProduct extends Product { }

Now I call the following query:

1 select p from product p where TREAT(p AS variant_product).baseProduct is null and p.catalogVersion in :catalogVersions

and I get the following exception:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: i.getText().equals("treat") [select p from com.nemesis.platform.module.commerce.core.entity.catalog.ProductEntity p where TREAT(p AS variant_product).baseProduct is null and p.catalogVersion in :catalogVersions] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) ... 208 more

I marked it as critical because I think this breaks the JPA specification.

Environment

None

Status

Assignee

Unassigned

Reporter

Petar Tahchiev

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Priority

Critical
Configure