[Lada-commits] [PATCH 05 of 13] Added AND NOT to query builder

Wald Commits scm-commit at wald.intevation.org
Fri May 29 11:48:15 CEST 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1432300424 -7200
# Node ID d61f5ded953da474f053f9b43ab12380d53a9bd7
# Parent  e6564d5fdc7acc505a5248e65d4c389dad1c6615
Added AND NOT to query builder.

diff -r e6564d5fdc7a -r d61f5ded953d src/main/java/de/intevation/lada/util/data/QueryBuilder.java
--- a/src/main/java/de/intevation/lada/util/data/QueryBuilder.java	Fri May 22 15:12:54 2015 +0200
+++ b/src/main/java/de/intevation/lada/util/data/QueryBuilder.java	Fri May 22 15:13:44 2015 +0200
@@ -76,6 +76,24 @@
     }
 
     /**
+     * Logical AND NOT operation.
+     *
+     * @param id    The database column name.
+     * @param value The filter value
+     * @return The builder itself.
+     */
+    public QueryBuilder<T> andNot(String id, Object value) {
+        Predicate p = this.builder.equal(this.root.get(id), value);
+        if (this.filter != null) {
+            this.filter = this.builder.and(this.filter, p).not();
+        }
+        else {
+            this.filter = this.builder.and(p).not();
+        }
+        return this;
+    }
+
+    /**
      * Logical AND with like operation.
      *
      * @param id    The database column name.


More information about the Lada-commits mailing list