0

我想用list放入查询结果,数据库有两个数据,但是list中有四个结果,为什么要重复查询

    <select id="selectList" resultType="map" >
        <foreach collection="list" item="items" separator=" union all ">
            SELECT
            #{items.id,jdbcType=INTEGER} id,
            #{items.name,jdbcType=VARCHAR} name
            FROM category
        </foreach>
    </select>
    public void selectList() {
        Map<String, Object> map1 = new HashMap<>();
        map1.put("name", "haha");
        map1.put("id", "1");

        Map<String, Object> map2 = new HashMap<>();
        map2.put("name", "update");
        map2.put("id", "2");

        List<Map<String, Object>> list = new ArrayList<>();
        list.add(map1);
        list.add(map2);

        List<Map<String, Object>> resultList = categoryDao.selectList(list);
        for (Map<String,Object> m : resultList){
            System.out.println(m.toString());
        }
    }

}

在此处输入图像描述

在此处输入图像描述

为什么这里有四个?

4

0 回答 0