HQL左的连接,其中左边是空
问题描述:
如何写这个的HQL查询:HQL左的连接,其中左边是空
select pp.*
from Part pp
left join Product p on pp.ProductID = p.ID
where p.ID is null
我需要无产品部分。部分有产权产品(多到一个)
我试图
from Part p
where p.Product is null
但它产生无效的查询。
感谢
答
解决了与:
from Part p
where not exists (from Product pr where p.Product = pr)
更新: 而这正是因为在SQL!
from Part p
left join p.Product as pr
where pr is null
答
from Part p
where p.Product.Id is null
应该工作 虽然你的查询还应该工作。生成的查询是什么?