java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate]

Hibernate JIRA | Sergey Lysenko | 3 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Sorry, my issue was closed and redirect me to forum but it is a real BIG PROBLEM: (I try write this query with EclipseLink and it is works!!!!!!!!!!) java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331) Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91) at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:284) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) 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:88) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1796) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328) ... 2 more There some entities and HQL query: {quote} @Entity public class Visit implements Serializable{ @Id private Integer id; @JoinColumn(name = "ID_SLUCH_MED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Sluch idSluchMed; @Temporal(TemporalType.TIMESTAMP) private Date visitDate; } @Entity public class Sluch implements Serializable { @Id private Integer id; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSluchMed", fetch = FetchType.LAZY) private List<Visit> visitList; } @Entity public class Insured implements Serializable { @Id private Integer id; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<Sluch> sluchList; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<HistInvalid> histInvalidList; } @Entity public class HistInvalid implements Serializable { @Id private Integer id; @Column(name = "BEGDATE") @Temporal(TemporalType.TIMESTAMP) private Date begdate; @Column(name = "ENDDATE") @Temporal(TemporalType.TIMESTAMP) private Date enddate; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; } SELECT v FROM Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate {quote} And I have the above exception!!!!

    Hibernate JIRA | 3 years ago | Sergey Lysenko
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate]
  2. 0

    Sorry, my issue was closed and redirect me to forum but it is a real BIG PROBLEM: (I try write this query with EclipseLink and it is works!!!!!!!!!!) java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331) Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate] at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91) at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:284) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206) 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:88) at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190) at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1796) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328) ... 2 more There some entities and HQL query: {quote} @Entity public class Visit implements Serializable{ @Id private Integer id; @JoinColumn(name = "ID_SLUCH_MED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Sluch idSluchMed; @Temporal(TemporalType.TIMESTAMP) private Date visitDate; } @Entity public class Sluch implements Serializable { @Id private Integer id; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idSluchMed", fetch = FetchType.LAZY) private List<Visit> visitList; } @Entity public class Insured implements Serializable { @Id private Integer id; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<Sluch> sluchList; @OneToMany(cascade = CascadeType.ALL, mappedBy = "idInsured", fetch = FetchType.LAZY) private List<HistInvalid> histInvalidList; } @Entity public class HistInvalid implements Serializable { @Id private Integer id; @Column(name = "BEGDATE") @Temporal(TemporalType.TIMESTAMP) private Date begdate; @Column(name = "ENDDATE") @Temporal(TemporalType.TIMESTAMP) private Date enddate; @JoinColumn(name = "ID_INSURED", referencedColumnName = "ID", nullable = false) @ManyToOne(optional = false, fetch = FetchType.LAZY) private Insured idInsured; } SELECT v FROM Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate {quote} And I have the above exception!!!!

    Hibernate JIRA | 3 years ago | Sergey Lysenko
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate]
  3. 0

    This might be related to HHH-10561. When performing a join 'x' on a treated join 'y', the join x is not rendered in the resulting HQL, resulting in 'Invalid path' errors. This is best illustrated by an example, the following query: {code} Root<RefEntity> root = criteria.from(RefEntity.class); Join<SubType, RefBySubType> join = cb.treat( root.<RefEntity, BaseType> join("other"), SubType.class) .<SubType, RefBySubType> join("refBySubtype"); criteria.where(cb.equal(join.<Integer> get("myvalue"), 42)); {code} Renders the following HQL: {code} select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42 {code} The second join to 'refBySubType' is not added to the query, resulting in the following exception: {code} java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1679) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:551) at org.hibernate.jpa.criteria.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:319) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:130) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:699) at org.hibernate.bugs.JPAUnitTestCase.hhh123Test(JPAUnitTestCase.java:49) 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: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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42] 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.analyze(QueryTranslatorImpl.java:268) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) 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:531) ... 29 more {code} I've attached the testcase demonstrating this problem. The testcase is against 5.1, but we see the same problen in 4.3.10 (WildFly 9.0.2).

    Hibernate JIRA | 10 months ago | Emond Papegaaij
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    This might be related to HHH-10561. When performing a join 'x' on a treated join 'y', the join x is not rendered in the resulting HQL, resulting in 'Invalid path' errors. This is best illustrated by an example, the following query: {code} Root<RefEntity> root = criteria.from(RefEntity.class); Join<SubType, RefBySubType> join = cb.treat( root.<RefEntity, BaseType> join("other"), SubType.class) .<SubType, RefBySubType> join("refBySubtype"); criteria.where(cb.equal(join.<Integer> get("myvalue"), 42)); {code} Renders the following HQL: {code} select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42 {code} The second join to 'refBySubType' is not added to the query, resulting in the following exception: {code} java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1679) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:551) at org.hibernate.jpa.criteria.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:319) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:130) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:699) at org.hibernate.bugs.JPAUnitTestCase.hhh123Test(JPAUnitTestCase.java:49) 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: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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42] 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.analyze(QueryTranslatorImpl.java:268) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) 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:531) ... 29 more {code} I've attached the testcase demonstrating this problem. The testcase is against 5.1, but we see the same problen in 4.3.10 (WildFly 9.0.2).

    Hibernate JIRA | 10 months ago | Emond Papegaaij
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias2.myvalue' [select generatedAlias0 from org.hibernate.bugs.RefEntity as generatedAlias0 inner join generatedAlias0.other as generatedAlias1 where generatedAlias2.myvalue=42]
  6. 0

    When treating the root of a query as a subclass, joins on the treated root are not rendered in the resulting HQL, resulting in 'Invalid path' errors. For example, the following query: {code} CriteriaQuery<Cheese> criteria = cb.createQuery(Cheese.class); Root<Cheese> root = criteria.from(Cheese.class); Root<SmellyCheese> treatedRoot = cb.treat(root, SmellyCheese.class); criteria.where( cb.equal( treatedRoot.<SmellyCheese, Smell>join("odour").<String>get("name"), "real bad")); entityManager.createQuery(criteria.select(treatedRoot)).getSingleResult(); {code} Renders the following HQL: {code} select treat(generatedAlias0 as org.hibernate.bugs.SmellyCheese) from org.hibernate.bugs.Cheese as generatedAlias0 where generatedAlias1.name=:param0 {code} The join to Smell is not part of the resulting query, causing the following stacktrace when trying to execute the query: {code} java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias1.name' [select treat(generatedAlias0 as org.hibernate.bugs.SmellyCheese) from org.hibernate.bugs.Cheese as generatedAlias0 where generatedAlias1.name=:param0] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1679) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1608) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:551) at org.hibernate.jpa.criteria.CriteriaQueryImpl$1.buildCompiledQuery(CriteriaQueryImpl.java:319) at org.hibernate.jpa.criteria.compile.CriteriaCompiler.compile(CriteriaCompiler.java:130) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:699) at org.hibernate.bugs.JPAUnitTestCase.hhh123Test(JPAUnitTestCase.java:44) 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: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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) 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.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192) Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias1.name' [select treat(generatedAlias0 as org.hibernate.bugs.SmellyCheese) from org.hibernate.bugs.Cheese as generatedAlias0 where generatedAlias1.name=:param0] 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.analyze(QueryTranslatorImpl.java:268) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190) 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:298) at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236) at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1821) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:531) ... 29 more {code} For this simple query, a work around is to start the query on SmellyCheese, eliminating the treat entirely, but in more complex situations (like dynamically generated queries), this is not always possible.

    Hibernate JIRA | 1 year ago | Emond Papegaaij
    java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Invalid path: 'generatedAlias1.name' [select treat(generatedAlias0 as org.hibernate.bugs.SmellyCheese) from org.hibernate.bugs.Cheese as generatedAlias0 where generatedAlias1.name=:param0]

  1. tomthomas 50 times, last 1 week ago
  2. richard77 1 times, last 3 months ago
  3. MoYapro 2 times, last 4 months ago
  4. marcbouvierdav 1 times, last 5 months ago
  5. tfr 1 times, last 8 months ago
1 more registered users
31 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.hql.internal.ast.QuerySyntaxException

    with-clause referenced two different from-clause elements [SELECT v FROM com.imc.lpu.core.entity.Visit v LEFT JOIN v.idSluchMed s LEFT JOIN s.idInsured i LEFT JOIN i.histInvalidList h ON h.begdate < v.visitDate]

    at org.hibernate.hql.internal.ast.QuerySyntaxException.convert()
  2. Hibernate
    SessionImpl.createQuery
    1. org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:91)
    2. org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:109)
    3. org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:284)
    4. org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:206)
    5. org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158)
    6. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:126)
    7. org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:88)
    8. org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:190)
    9. org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:301)
    10. org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:236)
    11. org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1796)
    11 frames
  3. org.hibernate.jpa
    AbstractEntityManagerImpl.createQuery
    1. org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:328)
    2. org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
    3. org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331)
    3 frames