Bean :
public class XXXBean {
private String id;
private List<Bean> ListName;
Getter and Setter 。。。。。。
}
Service :
public interface XXXXService {
int name(XXXXXBean xxxxxBean);
}
这里的 name 要和 xml 中的 id 中的对应的 name 对应起来!
XML:
<mapper namespace="XXXService">
<insert id="name" parameterType="XXXXXBean">
INSERT INTO TableName(id,name,age)
<foreach item="item" index="index" collection="ListName" separator="union all">
(select
#{id,jdbcType=VARCHAR}
,#{item.name,jdbcType=VARCHAR}
,#{item.age,jdbcType=VARCHAR}
from dual)
</foreach>
</insert>
XXXService : 就是跳转的接口。
插入数据库的字段中,id 就是String类型的值,其中 name , age 是 XXXXBean 中的一个 List<Bean> ListName 中的属性。