【问题标题】:What is the use of Hbernate IN keyword before where clause在 where 子句之前使用 Hibernate IN 关键字有什么用
【发布时间】:2014-12-05 10:36:28
【问题描述】:

在我的项目中,我发现了以下语法

createQuery("select stuInfo from StudentInfo stuInfo, IN(stuInfo.studentList) studentList "
    + "where stuInfo.completed =:completed and studentList.Date is null");

我尝试谷歌一下,IN关键字在where子句前有什么用,但我没有找到任何关于这个概念的解释。

【问题讨论】:

  • 你有任何证据证明它是合法的 HQL 语法吗?
  • 我无法为您提供任何证据,但我可以说这个查询在我过去 2 年的项目中有效,在调试期间我发现了这个。
  • 那么StudentInfo.studentList的类型是什么?
  • 检查它产生的sql
  • studentList 是另一个表,与 StudentInfo 映射为@OneToMany

标签: java sql hibernate jpql


【解决方案1】:

我已经检查过了,在你的情况下,它只是 INNER JOIN 的简写

select stuInfo from StudentInfo stuInfo inner join stuInfo.studentList studentList ...

实际上使用别名 student 而不是 studentList 更有意义,因为这就是您所指的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-08
    • 1970-01-01
    • 2023-03-29
    • 2014-09-10
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多