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()));