1 | public class NotNullExpression implements Criterion {↵ | | 1 | public class NullExpression implements Criterion {↵
|
|
2 | private final String propertyName;↵ | | 2 | private final String propertyName;↵
|
|
3 | private static final TypedValue[] NO_VALUES = new TypedValue[0];↵ | | 3 | private static final TypedValue[] NO_VALUES = new TypedValue[0];↵
|
|
4 | protected NotNullExpression(String propertyName) {↵ | | 4 | protected NullExpression(String propertyName) {↵
|
5 | this.propertyName = propertyName;↵ | | 5 | this.propertyName = propertyName;↵
|
6 | }↵ | | 6 | }↵
|
|
7 | public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery)↵ | | 7 | public String toSqlString(Criteria criteria, CriteriaQuery criteriaQuery) ↵
|
8 | throws HibernateException {↵ | | 8 | throws HibernateException {↵
|
9 | String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);↵ | | 9 | String[] columns = criteriaQuery.getColumnsUsingProjection(criteria, propertyName);↵
|
10 | String result = StringHelper.join(↵ | | 10 | String result = StringHelper.join(↵
|
11 | " or ",↵ | | 11 | " and ",↵
|
12 | StringHelper.suffix( columns, " is not null" )↵ | | 12 | StringHelper.suffix( columns, " is null" )↵
|
13 | );↵ | | 13 | );↵
|
14 | if (columns.length>1) result = '(' + result + ')';↵ | | 14 | if (columns.length>1) result = '(' + result + ')';↵
|
15 | return result;↵ | | 15 | return result;↵
|
|
16 | //TODO: get SQL rendering out of this package!↵ | | 16 | //TODO: get SQL rendering out of this package!↵
|
17 | }↵ | | 17 | }↵
|
|
18 | public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery)↵ | | 18 | public TypedValue[] getTypedValues(Criteria criteria, CriteriaQuery criteriaQuery) ↵
|
19 | throws HibernateException {↵ | | 19 | throws HibernateException {↵
|
20 | return NO_VALUES;↵ | | 20 | return NO_VALUES;↵
|
21 | }↵ | | 21 | }↵
|
|
22 | public String toString() {↵ | | 22 | public String toString() {↵
|
23 | return propertyName + " is not null" | | 23 | return propertyName + " is null"
|