大家好: 我正在研究HQL
任何人都可以解释或提供一些关于 HQL 中WITH 和 WHERE 之间不同之处的链接吗?
来自 http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html
例如:
from Cat as cat left join cat.kittens as kitten with kitten.bodyWeight > 10.0
我可以将 with 替换为 where 吗?
谢谢
最佳答案
With
用于“提供额外的连接条件”,这意味着它被添加到连接而不是 where 子句中:
from Cat as cat
left join cat.kittens as kitten
with kitten.bodyWeight > 10.0
将被翻译成这样的内容;
from Cat as cat
left outer join Cat as kitten
on cat.id = kitten.mother_id
and kitten.bodyWeight > 10.0
此时
from Cat as cat
left join cat.kittens as kitten
where kitten.bodyWeight > 10.0
被翻译为
from Cat as cat
left outer join Cat as kitten
on cat.id = kitten.mother_id
where
kitten.bodyWeight > 10.0
关于hibernate hql 与WITH 和WHERE 之间的不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5815602/