
正文
hibernate处理null 时提示:Property path [...] does notreference a collection
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
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()));




![【JAVAEE】[No81]Struts2+Spring3+Hibernate4+Maven+EasyUI整合入门视频教程 【JAVAEE】[No81]Struts2+Spring3+Hibernate4+Maven+EasyUI整合入门视频教程](https://www.04ip.com/template/qe/style/noimg/12.jpg)
![[No81]Struts2+Spring3+Hibernate4+Maven+EasyUI整合入门视频教程 [No81]Struts2+Spring3+Hibernate4+Maven+EasyUI整合入门视频教程](https://www.04ip.com/template/qe/style/noimg/17.jpg)
