Hibernate判断某属性不为null 且不可为空时出现Property path [...] does notreference a collection 的问题
我们一般会写成isNotEmpty(propertyName)、isNotNull(propertyName)此时报都会报Property path [...] does notreference a collection异常,我们需要将不为空或空查询改为Property.forName("isCancelled").isNotNull(),即为:criteria.add(Restrictions.or(Property.forName("isCancelled").isNotNull(),Restrictions.ne("isCancelled",null))); ions.ne("lqprovince", "")); 或者criteria.add(Restrictions.or(Restrictions.ne("isCancelled",null), Property.forName("isCancelled").isNotNull()));
ok,搞定了。