一个不愿透露姓名的糕 2019-07-22 10:10 采纳率: 57.1%
浏览 1343
已结题

mybatis insert 实体类的时候 实体类有个字段是集合 这样的数据可以for each进去吗 具体怎么写

private String a ;
private List<String> b;
private String c;


xml配置文件
 <resultMap type="xMain" id="xResult">
      <result property="a"    column="a"    />
      <result property="c"    column="c"    />
</resultMap>


 <insert id="insertMain" parameterType="xMain">

 ** 具体这里的foreach 的 b字段怎么写!!!!!!!!!!!!!**
 </insert>

我期望存入表中的 是

1: a b.get(1).x b.get(1)y c
2: a b.get(2).x b.get(2).y c
3: a b.get(3).x b.get(3)y c

就是集合有几条 就一次性通过mybatis的xml存进去

  • 写回答

2条回答 默认 最新

  • 关注

    我现在的解决方案是 在后台循环 不过这样可能数据量大话效率不高吧?

    评论

报告相同问题?