buyax 2017-08-28 01:17 采纳率: 53.3%
浏览 756
已结题

请教大神,这个是注入的数据类型错了吗?

如题:我用sql查数据,查出来后,在代码那里,死活来了个long类型不能注入到integer类型,我知道的办法都用了,哪位大神帮忙看下

这条sql,

select type, count(*) from lzh_member_discuz_logs group by type;

这是数据库结果

图片说明

    public DiscuzLogsDTO selectForfum() {
        List<Map<Integer, Integer>> list = discuzLogsDAO.selectForumPosts();
        DiscuzLogsDTO discuzLogsDTO = new DiscuzLogsDTO();
        for (Map<Integer, Integer> map2 : list) {
            if (map2.get("type") == 1) {
                logger.info("sendPosts :  {}",map2.get("count(*)"));
                System.out.println("1");
                《问题在这,debug走到这里,会报错,long不能注入到integer》
                Integer integer = map2.get("count(*)").intValue();
                System.out.println("2");
                discuzLogsDTO.setSendPosts(integer);
                System.out.println("3");
            }
            if (map2.get("type") == 2) {
                logger.info("backPosts :  {}",map2.get("count(*)"));
                discuzLogsDTO.setBackPosts(map2.get("count(*)").intValue());
            }
        }
        return discuzLogsDTO;
    }

求助~~

  • 写回答

8条回答

  • 砸死接触 2017-08-28 01:28
    关注

    把intValue()去掉也报错吗?看代码,你的map2 的key明明是Integer类型。但是为什么你map2取值get的时候怎么成了String型?

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?