迭代Ibatis中的对象列表 [英] Iterate list of Objects in Ibatis

查看:68
本文介绍了迭代Ibatis中的对象列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个对象列表,我想迭代并访问ibatis sql中的特定字段。

I have a list of object where I want to iterate and access a particular field in ibatis sql.

Ex。

public Class Student
{
String id;
String name;
}

我将作为参数传递给学生对象列表(列表(学生))

并迭代访问每个对象bean的id。我该怎么做?

I will pass as parameter a List of Student object(List(Student))
and do iteration accessing the id for each object bean. How do I do this?

推荐答案

foreach -tag就是你要找的。示例:

The foreach-tag is what you are looking for. Example:

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

参见用户指南了解更多信息,请参见动态sql一章。

See the user guide for more info, chapter "dynamic sql".

顺便说一句,iBatis不再开发并被冻结,它现在被称为MyBatis,整个开发团队从Apache转移到新的MyBatis主页

By the way, iBatis is no longer developed and is frozen, it is now called "MyBatis" and the whole developer team moved away from Apache to the new MyBatis home.

这篇关于迭代Ibatis中的对象列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆