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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM