hibernate左连接查询时在easyUI的dataGrid中有些行取值为空的解决办法
生活随笔
收集整理的這篇文章主要介紹了
hibernate左连接查询时在easyUI的dataGrid中有些行取值为空的解决办法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1 當使用left join左連連接,sql語句為
select t from SecondPage t left join t.rightNavbar n where 1=1頁面中出現了部分空行的情況,上述語句返回的list集合為
DataGrid dataGrid = new DataGrid(); List<SecondPage> list=secondPageDao.find(model, paging);dataGrid.setRows(list); dataGrid.setTotal(secondPageDao.count(model)); return dataGrid;遍歷list的值,發現list里邊的每一項都是有值的,我就沒有理解,為什么直接把listset到row中,頁面上就是有空格存在,但是我加了下面代碼后解決了這個問題,如果有經驗的朋友歡迎提供說明
DataGrid dataGrid = new DataGrid();List<SecondPage> list=secondPageDao.find(model, paging);Iterator<SecondPage> it = list.iterator();/**解決空格的問題,前臺取不到值**/List<SecondPage> listCopy = new ArrayList<SecondPage>();while (it.hasNext()) {SecondPage s = (SecondPage) it.next();SecondPage copy = new SecondPage();BeanUtils.copyProperties(s, copy);listCopy.add(copy);}/**結束**/dataGrid.setRows(list);dataGrid.setTotal(secondPageDao.count(model));return dataGrid;總結
以上是生活随笔為你收集整理的hibernate左连接查询时在easyUI的dataGrid中有些行取值为空的解决办法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 百度统计代码怎么获取(百度统计代码怎么获
- 下一篇: 百度文库怎么收录(百度文库怎么收录视频)