5

Restrictions.or と Restrictions.and に関する小さな質問

私がこのようなことをすると:

...
criterion = criterionA;
criterion = Restrictions.and(criterion, criterionB);
criterion = Restrictions.or(criterion, criterionC);
criterion = Restrictions.and(criterion, criterionD);

これは次のように扱われますか。

(A and B) or (C and D) (following mathematical conventions)

または、制限が追加された順序で処理されますか。

(((A and B) or C) and D)

参考文献などありましたらお願いします。...

4

2 に答える 2

6

後者として扱うべき

(((A and B) or C) and D)

あなたができる

criterion = Restriction.or(Restrictions.and(criterionA, criterionB), Restrictions.and(criterionC, criterionD))

最初の解決策が必要な場合

于 2009-06-26T09:47:09.573 に答える
2

(プログラミング言語や CFG パーサーのような) 優先順位の規則はなく、メソッド呼び出しの順序は明確に式を決定します。

(A and B) または (C and D) は、次のように翻訳する必要があります。

import static org.hibernate.criterion.Restrictions.*;
...
criterion = or(and(A, B), and(C,D));
于 2009-06-26T09:47:13.117 に答える