11.2.3.2.3. ブール値の条件
以下の例では、複数の属性条件を論理結合 (and) および非結合 (or) 演算子と組み合わせて、より複雑な条件を作成する方法を示しています。ブール演算子のよく知られている演算子の優先順位ルールはここで適用されるので、構築時の DSL メソッド呼び出しの順序は無関係です。ここで、or が最初に呼び出された場合でも、and Operator の優先順位は or よりも高くなります。
// match all books that have "Data Grid" in their title
// or have an author named "Manik" and their description contains "clustering"
Query query = queryFactory.from(Book.class)
.having("title").like("%Data Grid%")
.or().having("author.name").eq("Manik")
.and().having("description").like("%clustering%")
.build();
ブール値の否定は not 演算子で達成されます。
// match all books that do not have "Data Grid" in their title and are authored by "Manik"
Query query = queryFactory.from(Book.class)
.not().having("title").like("%Data Grid%")
.and().having("author.name").eq("Manik")
.build();