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;
    
  • 相关阅读:
    JS 随机整数
    微信小程序 功能函数 支付接口
    JS 正则表达式
    JS 日期 自动补齐 “2017-11-22 14:43”
    schema get_ddl
    StringBuffer 清空
    java中split任意数量的空白字符
    美国法官工资
    纪检委,检察院的工资
    国家司法机构
  • 原文地址:https://www.cnblogs.com/sean-zeng/p/11024807.html
Copyright © 2011-2022 走看看