【Hibernate】could not instantiate class.. from tuple] with root cause
生活随笔
收集整理的這篇文章主要介紹了
【Hibernate】could not instantiate class.. from tuple] with root cause
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用hibernate的過程中出現了這個問題,查詢語句如下:
1 String hql = "select new GoodsBean(id, name, price, proPic, sales, updatetime, marketReferencePrice) from GoodsBean where bigTypeId = ? order by views desc"; 2 3 Query query = this.getCurrentSession().createQuery(hql); 4 query.setInteger(0, Integer.valueOf(bid)); 5 query.setFirstResult((p - 1) * pageSize); 6 query.setMaxResults(pageSize); 7 List<GoodsBean> goodsBeanList = (List<GoodsBean>)query.list();運行到第七行時出現題目中的錯誤提示,最后在網上查詢資料,說是可能是入參為null,我看了下數據庫構造函數中的各參數,果真有一個參數的值為空,賦值后,正常了。
1 new GoodsBean(id, name, price, proPic, sales, updatetime, marketReferencePrice)參考:https://blog.csdn.net/sunzhemin/article/details/9214435?locationnum=9
轉載于:https://www.cnblogs.com/sijizhen/p/10042348.html
總結
以上是生活随笔為你收集整理的【Hibernate】could not instantiate class.. from tuple] with root cause的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 实战项目-网易
- 下一篇: GridView Bind 短日期 格式