java.lang.IllegalArgumentException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Applying an EntityGraph as a loadgraph fails if the query contains a collection function that results in a subquery. Consider the following snippet: {code:java} // Create the entity graph EntityGraph<A> graph = entityManager.createEntityGraph(A.class); graph.addSubgraph("bs", B.class); // Perform a query that requires a subquery entityManager.createQuery("SELECT a FROM A a WHERE NOT a.bs IS EMPTY").setHint("javax.persistence.loadgraph", graph).getResultList(); {code} This results in the following stack trace: {code} java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) at com.example.IssueTest.testEntityGraphsAreNotAppliedToSubqueries(IssueTest.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.QueryException.generateQueryException(QueryException.java:137) at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:568) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ... 29 more Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1978) at org.hibernate.persister.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:1601) at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:367) at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:500) at org.hibernate.engine.query.spi.EntityGraphQueryHint.getFromElements(EntityGraphQueryHint.java:95) at org.hibernate.engine.query.spi.EntityGraphQueryHint.toFromElements(EntityGraphQueryHint.java:68) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:676) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:665) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4905) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4606) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2104) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:796) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:597) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) ... 34 more {code} This happens because the EntityGraphQueryHint#toFromElements tries to apply the EntityGraph to the subquery - which is not of type A but of type B. Consequently the query translation fails. The offending piece of code is in EntityGraphQueryHint#toFromElements line 65ff: {code} return getFromElements( originEntityGraph.getAttributeNodes(), fromClause.getFromElement(), fromClause, walker, explicitFetches ); {code} The issue can be fixed for me by replacing the above piece of code with this: {code} return getFromElements( fromClause.getLevel() == FromClause.ROOT_LEVEL ? originEntityGraph.getAttributeNodes() : Collections.emptyList(), fromClause.getFromElement(), fromClause, walker, explicitFetches ); {code} While I am pretty sure that this crude modification is not the desired fix I hope it helps fixing the issue. Please find attached a patch for org.hibernate.jpa.test.graphs.EntityGraphTest that adds a test case to reproduce the issue using the existing hibernate-entitymanager test harness. If I can assist any further in fixing this issue please let me know.
    via by Alex Stockinger,
  • Applying an EntityGraph as a loadgraph fails if the query contains a collection function that results in a subquery. Consider the following snippet: {code:java} // Create the entity graph EntityGraph<A> graph = entityManager.createEntityGraph(A.class); graph.addSubgraph("bs", B.class); // Perform a query that requires a subquery entityManager.createQuery("SELECT a FROM A a WHERE NOT a.bs IS EMPTY").setHint("javax.persistence.loadgraph", graph).getResultList(); {code} This results in the following stack trace: {code} java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) at com.example.IssueTest.testEntityGraphsAreNotAppliedToSubqueries(IssueTest.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.QueryException.generateQueryException(QueryException.java:137) at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:568) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ... 29 more Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1978) at org.hibernate.persister.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:1601) at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:367) at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:500) at org.hibernate.engine.query.spi.EntityGraphQueryHint.getFromElements(EntityGraphQueryHint.java:95) at org.hibernate.engine.query.spi.EntityGraphQueryHint.toFromElements(EntityGraphQueryHint.java:68) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:676) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:665) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4905) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4606) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2104) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:796) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:597) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) ... 34 more {code} This happens because the EntityGraphQueryHint#toFromElements tries to apply the EntityGraph to the subquery - which is not of type A but of type B. Consequently the query translation fails. The offending piece of code is in EntityGraphQueryHint#toFromElements line 65ff: {code} return getFromElements( originEntityGraph.getAttributeNodes(), fromClause.getFromElement(), fromClause, walker, explicitFetches ); {code} The issue can be fixed for me by replacing the above piece of code with this: {code} return getFromElements( fromClause.getLevel() == FromClause.ROOT_LEVEL ? originEntityGraph.getAttributeNodes() : Collections.emptyList(), fromClause.getFromElement(), fromClause, walker, explicitFetches ); {code} While I am pretty sure that this crude modification is not the desired fix I hope it helps fixing the issue. Please find attached a patch for org.hibernate.jpa.test.graphs.EntityGraphTest that adds a test case to reproduce the issue using the existing hibernate-entitymanager test harness. If I can assist any further in fixing this issue please let me know.
    via by Alex Stockinger,
  • failed to process artwork
    via GitHub by jluc2808
    ,
  • addJoin not working hibernate
    via Stack Overflow by Mckenzie
    ,
    • java.lang.IllegalArgumentException: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:458) at com.example.IssueTest.testEntityGraphsAreNotAppliedToSubqueries(IssueTest.java:42) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.junit.runner.JUnitCore.run(JUnitCore.java:160) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134) Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B [SELECT a FROM com.example.entities.A a WHERE NOT a.bs IS EMPTY] at org.hibernate.QueryException.generateQueryException(QueryException.java:137) at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:120) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:234) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:93) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:568) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) ... 29 more Caused by: org.hibernate.QueryException: could not resolve property: bs of: com.example.entities.B at org.hibernate.persister.entity.AbstractPropertyMapping.propertyException(AbstractPropertyMapping.java:83) at org.hibernate.persister.entity.AbstractPropertyMapping.toType(AbstractPropertyMapping.java:77) at org.hibernate.persister.entity.AbstractEntityPersister.toType(AbstractEntityPersister.java:1978) at org.hibernate.persister.collection.AbstractCollectionPersister.toType(AbstractCollectionPersister.java:1601) at org.hibernate.hql.internal.ast.tree.FromElementType.getPropertyType(FromElementType.java:367) at org.hibernate.hql.internal.ast.tree.FromElement.getPropertyType(FromElement.java:500) at org.hibernate.engine.query.spi.EntityGraphQueryHint.getFromElements(EntityGraphQueryHint.java:95) at org.hibernate.engine.query.spi.EntityGraphQueryHint.toFromElements(EntityGraphQueryHint.java:68) at org.hibernate.hql.internal.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:676) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:665) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.collectionFunctionOrSubselect(HqlSqlBaseWalker.java:4905) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.comparisonExpr(HqlSqlBaseWalker.java:4606) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2104) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.logicalExpr(HqlSqlBaseWalker.java:2079) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.whereClause(HqlSqlBaseWalker.java:796) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:597) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:278) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) ... 34 more

    Users with the same issue

    slash
    13 times, last one,
    derprogger
    2 times, last one,
    tvrmsmith
    11 times, last one,
    tomthomas
    3 times, last one,
    DoktorDoener666
    1 times, last one,
    6 more bugmates