We're updating the issue view to help you get more done. 

Restrictions.eq when passed null, should create a NullRestriction

Description

If you create a Restriction using eq, and pass null to it, then the generated SQL is "where foo = null", which always returns false.

The programmer will almost certainly have intended to get "where foo is null".

Ideally, we could change:
public static SimpleExpression eq(String propertyName, Object value) {
return new SimpleExpression(propertyName, value, "=");
}

to

public static SimpleExpression eq(String propertyName, Object value) {
if (value == null) {
return isNull(propertyName);
}
else {
return new SimpleExpression(propertyName, value, "=");
}
}

Unforunately that wont work, as isNull doesn't return a SimpleExpression.

Environment

None

Status

Assignee

Brett Meyer

Reporter

David Sheldon

Components

Fix versions

Affects versions

3.2.1

Priority

Trivial