xrc*_*wrn 56 hibernate hql dereference jpa-2.0 jpa-2.1
我正在尝试跟随hql查询执行
SELECT count(*)
FROM BillDetails as bd
WHERE bd.billProductSet.product.id = 1002
AND bd.client.id = 1
Run Code Online (Sandbox Code Playgroud)
但它正在显示
org.hibernate.QueryException: illegal attempt to dereference collection
[billdetail0_.bill_no.billProductSet] with element property reference [product]
[select count(*) from iland.hbm.BillDetails as bd where bd.billProductSet.product.id=1001 and bd.client.id=1]
at org.hibernate.hql.ast.tree.DotNode$1.buildIllegalCollectionDereferenceException(DotNode.java:68)
at org.hibernate.hql.ast.tree.DotNode.checkLhsIsNotCollection(DotNode.java:558)
Run Code Online (Sandbox Code Playgroud)
kos*_*tja 121
billProductSet
是一个Collection
.因此,它没有名为的属性product
.
Product
是一个属性的元素的此Collection
.
您可以通过加入集合而不是取消引用它来解决问题:
SELECT count(*)
FROM BillDetails bd
JOIN bd.billProductSet bps
WHERE bd.client.id = 1
AND bps.product.id = 1002
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
44013 次 |
最近记录: |