【问题标题】:HQL Left Outer Join in case of two non Relational Objects在两个非关系对象的情况下,HQL 左外连接
【发布时间】:2016-05-26 13:24:12
【问题描述】:

我有两个没有任何关系的表,我想写HQL来得到结果,下面是我的HQL查询

SELECT P.prcCatIdNo ,P.prcClsCd , 
  P.prcTypCd ,P.catIdNm ,P.boxQty ,P.prcUmAbr ,P.sellPrc 
  FROM Table1 P LEFT OUTER JOIN Table2 L ON P.prcCatIdNo = L.ident

但我得到以下异常

org.hibernate.hql.ast.QuerySyntaxException: Path expected for join!

谁能帮帮我。

【问题讨论】:

    标签: hibernate join hql


    【解决方案1】:

    您需要 Hibernate 5.1 才能使用临时连接。

    Join unrelated entities in JPA

    或者你可以使用cross join

    SELECT P.prcCatIdNo, P.prcClsCd, 
      P.prcTypCd, P.catIdNm, P.boxQty, P.prcUmAbr, P.sellPrc 
      FROM Table1 P, Table2 L where P.prcCatIdNo = L.ident
    

    这是一个inner join

    看起来连接毫无意义,因为您没有从 Table2 获得任何列。

    【讨论】:

      猜你喜欢
      • 2013-01-23
      • 2013-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-03
      • 1970-01-01
      相关资源
      最近更新 更多