簡體   English   中英

如何在jOOQ中結合條件

[英]How to combine Conditions in jOOQ

我有一份條件清單:

List<Condition> conditions = ...;

將這些條件組合(或組合)成新條件的最簡單方法是什么?

Condition condition = and(conditions);

JOOQ是否具有實用功能? 我同意這很容易寫,但我寧願不重新發明輪子。

jOOQ 3.6+解決方案。

你可以簡單地寫:

Condition condition = DSL.and(conditions);

在jOOQ 3.6之前:

在jOOQ 3.6( #3904 )中實現之前,你不得不求助於編寫自己的方法:

static Condition and(Collection<? extends Condition> conditions) {
    Condition result = DSL.trueCondition();

    for (Condition condition : conditions)
        result = result.and(condition);

    return result;
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM