我有一个对象列表,我想在其中迭代并访问 ibatis sql 中的特定字段。
例。
public Class Student
{
String id;
String name;
}
我将作为参数传递一个 Student 对象列表(List(Student))
并迭代访问每个对象 bean 的 id。我该怎么做?
最佳答案
foreach 标签就是您要查找的内容。示例:
<select id="selectPostIn" resultType="domain.blog.Post">
SELECT *
FROM POST P
WHERE ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
参见 user guide有关详细信息,请参阅“动态 sql”一章。
顺便说一句,iBatis 不再开发并被卡住,现在称为“MyBatis”,整个开发团队从 Apache 转移到 new MyBatis home .
关于java - 在 Ibatis 中迭代对象列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3360070/