簡體   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