简体   繁体   English

Hibernate Criteria Restrictions AND combination With in 子句

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

I am using Hibernate 4.3.8我正在使用 Hibernate 4.3.8

How would I achieve this using Hibernate Restrictions?我将如何使用 Hibernate 限制来实现这一目标?

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

If col_1 and col_2 are part of an embeddable, you can use it like select e from Entity e where e.embeddable in (:embeddable1, :embeddable2) and pass embeddables accordingly.如果col_1col_2是可嵌入对象的一部分,您可以使用它, select e from Entity e where e.embeddable in (:embeddable1, :embeddable2)并相应地传递可嵌入对象。 Note though, that this version of Hibernate does not yet support emulating row value constructors, so it depends on the DBMS you are using, if this works.但请注意,此版本的 Hibernate 尚不支持模拟行值构造函数,因此它取决于您使用的 DBMS,如果这可行。 You can emulate this though by doing:您可以通过执行以下操作来模拟这一点:

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