将列表传递给MyBatis。我们可以将多个输入传递给IN用于SELECT语句,如下所述。请纠正我
dao interface:
public List<Integer> getObjects(List<Test> testList)
Mybatis :
<select id="getObjects" resultType = "Integer">
SELECT KEY FROM TABLEA WHERE number IN(<foreach collection="TEST"
index="index" item="item" separator=", ">
#{number}
</foreach>)
答案 0 :(得分:0)
以下代码可行:
<select id="getObjects" resultType = "Integer">
SELECT KEY FROM TABLEA WHERE number IN
(<foreach collection="list"
index="index" item="item" separator=", ">
#{item.number}
</foreach>)
</select>