DATACMNS-1578 - Proper handling of null values in QuerydslDefaultBinding.

We now properly use an ….isNull() binding if the value to be compared to is null.
This commit is contained in:
Colin Gao
2019-09-04 07:38:41 +12:00
committed by Oliver Drotbohm
parent 3ebe74d018
commit 30dbac1bce
2 changed files with 16 additions and 1 deletions

View File

@@ -38,6 +38,9 @@ import com.querydsl.core.types.dsl.SimpleExpression;
* @author Christoph Strobl
* @author Oliver Gierke
* @since 1.11
*
* @author Colin Gao
* @since 2.1
*/
class QuerydslDefaultBinding implements MultiValueBinding<Path<? extends Object>, Object> {
@@ -73,7 +76,12 @@ class QuerydslDefaultBinding implements MultiValueBinding<Path<? extends Object>
return Optional.of(((SimpleExpression) path).in(value));
}
return Optional.of(((SimpleExpression) path).eq(value.iterator().next()));
Object object = value.iterator().next();
if (object == null) {
return Optional.of(((SimpleExpression) path).isNull());
}
return Optional.of(((SimpleExpression) path).eq(object));
}
throw new IllegalArgumentException(