Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring iBatis 2.3.0中的传递列表参数_Spring_Mybatis_Ibatis - Fatal编程技术网

Spring iBatis 2.3.0中的传递列表参数

Spring iBatis 2.3.0中的传递列表参数,spring,mybatis,ibatis,Spring,Mybatis,Ibatis,我正在尝试将Long类型的列表传递给我的IBatis xml文件。代码如下: Java调用: List<Long> a; // This contains a list of id's Map<String,Object> params = new HashMap<String,Object>(); params.put("iArray",a); 我需要在我的sql中传递此id列表,在mapper xml上定义为: 从a-id列表中应该传递学生id的学生中

我正在尝试将Long类型的列表传递给我的IBatis xml文件。代码如下:

Java调用:

List<Long> a; // This contains a list of id's 
Map<String,Object> params = new HashMap<String,Object>();
params.put("iArray",a);
我需要在我的sql中传递此id列表,在mapper xml上定义为:

从a-id列表中应该传递学生id的学生中选择*


实现这一点的最佳方式是什么。请帮忙。我正在使用iBatis 2.3.0。

我不明白您为什么需要传递HashMap。您可以直接传递学生ID列表,如下所示

public List<Student> getStudents(List<String> list);
您的映射器xml如下所示

<select id="getStudents" parameterType="list" resultType="Student">
        SELECT * from students where studentId in
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

我不明白你为什么要通过HashMap。您可以直接传递学生ID列表,如下所示

public List<Student> getStudents(List<String> list);
您的映射器xml如下所示

<select id="getStudents" parameterType="list" resultType="Student">
        SELECT * from students where studentId in
        <foreach item="item" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>