Property path [...] does not reference a collection

criteria.add(Restrictions.or(Restrictions.ne("isCancelled", null), Restrictions.isNull("isCancelled")));
在使用hiberante查询时,“isCancelled” 字段的值可能为空值,使用isEmpty(propertyName)、isNull(propertyName)都会报Property path [...] does not reference a collection异常,将为空的查询改为 Property.forName("isCancelled").isNull()即:
criteria.add(Restrictions.or(Restrictions.ne("isCancelled", null), Property.forName("isCancelled").isNull()));
ok,搞定了。

你可能感兴趣的:(Collection)