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()));
本文解决在使用Hibernate进行数据库查询时,遇到的Propertypath[...]doesnotreferenceacollection异常。介绍了如何正确地使用isNotEmpty和isNotNull方法,并提供了解决方案。
4929

被折叠的 条评论
为什么被折叠?



