hibernate hql 与WITH 和WHERE 之间的不同

标签 hibernate hql

大家好: 我正在研究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/

相关文章:

java - 将sql转换为hql

java - HQL 检查 @param 中传递的列表大小

hql - 如何在 HQL 中访问元素零?

java - ORA-02289 : sequence does not exist when upgrade Hibernate 3 to hibernate 4

java - Hibernate - 集合的一对多映射 - 注解

bash - 将Oracle查询转换为配置单元

mysql - 使用多个 JOINS 将 MYSQL 查询转换为 HQL

java - 非法尝试将集合与 hibernate 中的两个打开 session 相关联

java - 基本的 HQL 语句总是失败

java - 是否可以使用 hibernate 实体类作为 GSON 的 POJO?