zoukankan      html  css  js  c++  java
  • 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;
    
  • 相关阅读:
    oracle-sql脚本
    vue生命周期
    使用vue搭建项目(创建手脚架)
    bootcss
    miniMobile(手机)
    mui(手机)
    layui
    Element
    如何学好Spring
    使用Vue做评论+localStorage存储(js模块化)
  • 原文地址:https://www.cnblogs.com/sean-zeng/p/11024807.html
Copyright © 2011-2022 走看看