问题:mybatis selectList接口,返回一个List<MyDomain> 对象列表;
查询出的结果 list.size()>0 遍历的时候发现有一个item是nullsql 类似
  select id,c1,c2,c3, max(id) as max_id
  from tab_1
  where .....

解决方案 »

  1.   

    描述不太清楚,既然是做了判断了 > 0 ,遍历除出来的null,有可能是你数据库的值有null
      

  2.   

    list.size()>0 && list.get(0)!=null 才能确定没有值,默认会有一个
      

  3.   

    if(list != null && list.size() > 0 && list.get(0) != null){

    }
    这样判断比较保险,或者自己写一个公共函数封装一下
      

  4.   

    select id,c1,c2,c3, max(id) as max_id
      from tab_1
      where .....
    返回的list中含有 nullselect id,c1,c2,c3
      from tab_1
      where ....
    返回的list中就不含null的值了
      

  5.   

    max(id) as 'max_id' 这个对结果有影响? 很奇怪啊
      

  6.   

    调用 了内置函数,比如 count也是如此,所以结果有且只有一行,除非你使用 groupby