这里是 HQL 菜鸟。如何在不使用 contains 子句的情况下重写此 HQL 查询。在 SQL 中,我可以连接 VisitorProfileField 表和 Visitor 表,并使用 AND 添加存在的条件。
但在普通的 HQL 中,我猜我无法克服一些语法违规。非常感谢您的帮助。
"select distinct v from Visitor v where v.id not in (select o.id from Operator o) " +
" and exists (select vpf from VisitorProfileField vpf " +
" where vpf.visitor = v and vpf.profileField.name = :subscription_field " +
" and vpf.numberVal = :type and vpf.stringVal = :manual) "
最佳答案
我不确定我是否明白你的查询的含义,但我猜是这样的:
select distinct vpf.visitor
from VisitorProfileField vpf
where vpf.profileField.name = :subscription_field
and vpf.numberVal = :type and vpf.stringVal = :manual
and vpf.visitor.id not in (select o.id from Operator o)
关于java - 帮助重写 HQL 查询(Hibernate 查询语言),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2096954/