[JIRA] (HHH-13905) "QueryException: could not resolve property" when upgrading from 5.3.15 to 5.4.x
by Fabian (JIRA)
Fabian ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... ) *created* an issue
Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiODc5NmMxZTk5... ) / Bug ( https://hibernate.atlassian.net/browse/HHH-13905?atlOrigin=eyJpIjoiODc5Nm... ) HHH-13905 ( https://hibernate.atlassian.net/browse/HHH-13905?atlOrigin=eyJpIjoiODc5Nm... ) "QueryException: could not resolve property" when upgrading from 5.3.15 to 5.4.x ( https://hibernate.atlassian.net/browse/HHH-13905?atlOrigin=eyJpIjoiODc5Nm... )
Issue Type: Bug Affects Versions: 5.4.0, 5.4.12 Assignee: Unassigned Created: 25/Mar/2020 02:59 AM Priority: Major Reporter: Fabian ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=557058%... )
Hi Hibernate Team,
I´m facing a strange error when upgrading Hibernate from 5.3.15 to 5.4.X. The query
SELECT b FROM Base b where b.middle.target.field = :value
starts to fail with
java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: field of: org.example.Base [SELECT b FROM org.example.Base b where b.middle.target.field = :value]
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:138)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:725)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:816)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:113)
at org.example.TestCase.issue(TestCase.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:45)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.QueryException: could not resolve property: field of: org.example.Base [SELECT b FROM org.example.Base b where b.middle.target.field = :value]
at org.hibernate.QueryException.generateQueryException(QueryException.java:120)
at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:220)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:144)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:113)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:73)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:155)
at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:604)
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:716)
... 18 more
Caused by: org.hibernate.QueryException: could not resolve property: field of: org.example.Base
at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:73)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:67)
at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:2044)
at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:412)
at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:516)
at org.hibernate.hql.internal.ast.tree.DotNode.getDataType(DotNode.java:690)
at org.hibernate.hql.internal.ast.tree.DotNode.prepareLhs(DotNode.java:268)
at org.hibernate.hql.internal.ast.tree.DotNode.resolve(DotNode.java:208)
at org.hibernate.hql.internal.ast.HqlSqlWalker.resolve(HqlSqlWalker.java:1045)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.expr(HqlSqlBaseWalker.java:1294)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.exprOrSubquery(HqlSqlBaseWalker.java:4715)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4183)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2147)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:819)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:613)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:317)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:265)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:272)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:192)
... 24 more
I´ve created the following repo for reproducing the issue https://github.com/Fabian-K/hibernate-issue. I tried to strip down the project as much as possible. The code works fine when using 5.3.15, it however fails with 5.4.x (I tested 5.4.0 and 5.4.12). You can reproduce it using mvn test.
It seems to be related to the use of Composite IDs for the Middle class. I already noticed that it works when
* renaming Middle.key to Middle.id and MiddleId.key to MiddleId.id
* not using a Composite ID for Middle
* using b.middle.target.id instead of b.middle.target.field in the where condition
Do you have any idea/hint about what is going on in this case?
Thanks, Fabian
( https://hibernate.atlassian.net/browse/HHH-13905#add-comment?atlOrigin=ey... ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-13905#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#100122- sha1:092c6a7 )
4 years, 9 months