org.hibernate.hql.internal.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?]

Hibernate JIRA | Brett Meyer | 3 years ago
  1. 0

    Simple example: {code} public class SimpleEntityWithAssociation { ... private Set associatedEntities = new HashSet(); ... {code} {code} public class SimpleAssociatedEntity { ... private SimpleEntityWithAssociation owner; ... {code} "select a from SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?" {code} org.hibernate.hql.internal.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?] at org.hibernate.hql.internal.ast.HqlSqlWalker.handleWithFragment(HqlSqlWalker.java:424) at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:399) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3779) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3565) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3443) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:263) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:87) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:300) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:238) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1779) at org.hibernate.test.hql.WithClauseTest.testWithJoinRHS(WithClauseTest.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62) {code}

    Hibernate JIRA | 3 years ago | Brett Meyer
    org.hibernate.hql.internal.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?]
  2. 0

    Simple example: {code} public class SimpleEntityWithAssociation { ... private Set associatedEntities = new HashSet(); ... {code} {code} public class SimpleAssociatedEntity { ... private SimpleEntityWithAssociation owner; ... {code} "select a from SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?" {code} org.hibernate.hql.internal.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?] at org.hibernate.hql.internal.ast.HqlSqlWalker.handleWithFragment(HqlSqlWalker.java:424) at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:399) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3779) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3565) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3443) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:263) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119) at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:87) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:300) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:238) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1779) at org.hibernate.test.hql.WithClauseTest.testWithJoinRHS(WithClauseTest.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62) {code}

    Hibernate JIRA | 3 years ago | Brett Meyer
    org.hibernate.hql.internal.ast.InvalidWithClauseException: with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?]

    Root Cause Analysis

    1. org.hibernate.hql.internal.ast.InvalidWithClauseException

      with-clause expressions did not reference from-clause element to which the with-clause was associated [select a from org.hibernate.test.hql.SimpleEntityWithAssociation as e LEFT JOIN e.associatedEntities as a WITH e.name=?]

      at org.hibernate.hql.internal.ast.HqlSqlWalker.handleWithFragment()
    2. Hibernate
      SessionImpl.createQuery
      1. org.hibernate.hql.internal.ast.HqlSqlWalker.handleWithFragment(HqlSqlWalker.java:424)
      2. org.hibernate.hql.internal.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:399)
      3. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3779)
      4. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3565)
      5. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3443)
      6. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706)
      7. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562)
      8. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
      9. org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
      10. org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:263)
      11. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:191)
      12. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143)
      13. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119)
      14. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:87)
      15. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)
      16. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:300)
      17. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:238)
      18. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1779)
      18 frames
    3. org.hibernate.test
      WithClauseTest.testWithJoinRHS
      1. org.hibernate.test.hql.WithClauseTest.testWithJoinRHS(WithClauseTest.java:179)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      4. java.lang.reflect.Method.invoke(Method.java:601)
      4 frames
    5. JUnit
      FrameworkMethod.invokeExplosively
      1. org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      2. org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      3. org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      3 frames
    6. A Hibernate O/RM Module
      ExtendedFrameworkMethod.invokeExplosively
      1. org.hibernate.testing.junit4.ExtendedFrameworkMethod.invokeExplosively(ExtendedFrameworkMethod.java:63)
      1 frame
    7. JUnit
      FailOnTimeout$StatementThread.run
      1. org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      2. org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      3. org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      4. org.junit.internal.runners.statements.FailOnTimeout$StatementThread.run(FailOnTimeout.java:62)
      4 frames