changeset 674:d61f5ded953d

Added AND NOT to query builder.
author Raimund Renkert <raimund.renkert@intevation.de>
date Fri, 22 May 2015 15:13:44 +0200
parents e6564d5fdc7a
children 331cd2bb3109
files src/main/java/de/intevation/lada/util/data/QueryBuilder.java
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)