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型?

    评论

报告相同问题?