分頁查詢最後幾頁查不到

INFO 2017/06/22 17:07:30:422  org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:158)  HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.asam.buz.business.organization.po.Servant#40288da65acfa6c3015ada5f7d00001a]            2017-06-22 17:07:30.424 [http-bio-8080-exec-4] ERROR c.a.b.b.userlog.service.impl.UserlogServiceImpl - No row with the given identifier exists: [com.asam.buz.business.organization.po.Servant#40288da65acfa6c3015ada5f7d00001a]

 

 ERROR 2017/06/22 17:07:30:427  com.opensymphony.xwork2.util.logging.commons.CommonsLogger.error(CommonsLogger.java:34)  com.asam.buz.business.userlog.service.impl.UserlogServiceImpl分頁實體異常No row with the given identifier exists: [com.asam.buz.business.organization.po.Servant#40288da65acfa6c3015ada5f7d00001a]            

 

 

數據庫表log共有數據2294

數據庫表log共有數據2294

 

Hibernate中Criteria的完整用法

http://blog.csdn.net/saindy5828/article/details/16893257

 

http://blog.csdn.net/linshutao/article/details/5486628

 

Hibernate提供了相當多的內置criterion類型(Restrictions 子類), 但是尤其有用的是可以允許

你直接使用SQL

List cats = sess.createCriteria(Cat.class)
.add( Restrictions.sql("lower({alias}.name) like lower(?)", "Fritz%", Hibernate.STRING) )
.list();

{alias}佔位符應當被替換爲被查詢實體的列別名。

Property實例是獲得一個條件的另外一種途徑。你可以通過調用Property.forName() 創建一個

使用add()方法加入條件時,預設是使用and來組合條件,如果要用or的方式來組合條件,則可以使用Restrictions.or()方法

 

在分頁的時候出現了一個bug,數據庫表log共有數據2294條,分頁時每頁有15條數據,共分150多頁,最後一頁可以查詢,因爲代碼中是按照末頁查詢的,但是倒數第二頁查詢的時候會報錯,分頁實體異常No row with the given identifier exists: [com.asam.buz.business.organization.po.Servant#40288da65acfa6c3015ada5f7d00001a]  ,說沒有相關的row存在,指的是這個servantpo中的sid不存在,是因爲後臺人員在刪除servant表數據的時候沒有將關聯的log數據同步刪除,所以log表中顯示的是2294條數據,但是查詢出來的可能只有1700多條,所以倒數的幾頁會出現報錯的情況          

 

發佈了20 篇原創文章 · 獲贊 5 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章