HQL选择错误

时间:2014-05-15 14:01:19

标签: hibernate hql

代码是

 String myQuery = "select c.orderId from com.model.Supplier su join com.model.Supplier su2  join su2.product P where su.product.OrderId = :Order and c.order != :Order ";
List<Order> myOrder= getCurrentSession().createQuery(myQuery.toString()).setParameter("Order", aOrder).list();

当执行上述行时,我在屏幕上出现了一个错误<

java.lang.IllegalStateException: DOT node with no left-hand-side!
    at org.hibernate.hql.ast.tree.DotNode.getLhs(DotNode.java:631)
    at org.hibernate.hql.ast.tree.DotNode.getDataType(DotNode.java:606)
    at org.hibernate.hql.ast.HqlSqlWalker.createFromJoinElement(HqlSqlWalker.java:383)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.joinElement(HqlSqlBaseWalker.java:3671)
    at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3452)

1 个答案:

答案 0 :(得分:0)

假设您的映射与外键等一样正确,我认为您需要指定连接,例如&#39; left join&#39;。

查看hibernate docs中的有效联接。