繁体   English   中英

Hibernate Criteria Restrictions AND combination With in 子句

[英]Hibernate Criteria Restrictions AND combination With in IN Clause

我正在使用 Hibernate 4.3.8

我将如何使用 Hibernate 限制来实现这一目标?

SELECT * FROM t1 WHERE ( col_1, col_2 ) IN (( 'a', 'b' ), ( 'c', 'd' ));

如果col_1col_2是可嵌入对象的一部分,您可以使用它, select e from Entity e where e.embeddable in (:embeddable1, :embeddable2)并相应地传递可嵌入对象。 但请注意,此版本的 Hibernate 尚不支持模拟行值构造函数,因此它取决于您使用的 DBMS,如果这可行。 您可以通过执行以下操作来模拟这一点:

select e
from Entity e
where e.col1 = 'a' and e.col2 = 'b'
   or e.col1 = 'c' and e.col2 = 'd' 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM