我有一个带有 @ElementCollection
和 @Enumerated(EnumType.ORDINAL)
的类集合属性
我正在尝试对该集合执行 in 语句,但是在生成的 sql 中我得到了这个 -> {non-qualified-property-ref} in (?)
我在创建 hql 本身时可能做错了什么。会不会是因为元素实际上是枚举值?
谢谢, 彼得
最佳答案
根据文档 (http://docs.jboss.org/hibernate/orm/3.3/reference/en/html/queryhql.html),您应该能够使用“in elements”表达式执行此操作:
select mother from Cat as mother, Cat as kit
where kit in elements(foo.kittens)
但是,Hibernate 中存在一个 Unresolved 错误...它无法像您预期的那样对枚举值起作用,请参阅:https://hibernate.onjira.com/browse/HHH-5159寻求解决方法。
关于java - Hql "in"语句不适用于 @ElementCollection,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8087820/