# HG changeset patch # User Raimund Renkert # Date 1485526310 -3600 # Node ID e36e42cbd1d8d4770b532d85e0f81b12d78ebc84 # Parent 9dfb52db6a0fc1871388c850567a653ae59e2973 Handle 'null' values in criteria queries. diff -r 9dfb52db6a0f -r e36e42cbd1d8 src/main/java/de/intevation/lada/util/data/QueryBuilder.java --- a/src/main/java/de/intevation/lada/util/data/QueryBuilder.java Fri Jan 27 15:10:01 2017 +0100 +++ b/src/main/java/de/intevation/lada/util/data/QueryBuilder.java Fri Jan 27 15:11:50 2017 +0100 @@ -68,7 +68,13 @@ * @return The builder itself. */ public QueryBuilder and(String id, Object value) { - Predicate p = this.builder.equal(this.root.get(id), value); + Predicate p; + if (value == null) { + p = this.builder.isNull(this.root.get(id)); + } + else { + p = this.builder.equal(this.root.get(id), value); + } if (this.filter != null) { this.filter = this.builder.and(this.filter, p); } @@ -117,7 +123,13 @@ * @return The builder itself. */ public QueryBuilder or(String id, Object value) { - Predicate p = this.builder.equal(this.root.get(id), value); + Predicate p; + if (value == null) { + p = this.builder.isNull(this.root.get(id)); + } + else { + p = this.builder.equal(this.root.get(id), value); + } if (this.filter != null) { this.filter = this.builder.or(this.filter, p); }