两个非关系对象的 HQL Left Outer Join

HQL Left Outer Join in case of two non Relational Objects

我有两个没有任何关系的表,我想写 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 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 中获得任何列。