美文网首页
mybatis 添加多条数据(动态 :表名,列名,值)

mybatis 添加多条数据(动态 :表名,列名,值)

作者: 黑狼_佩恩 | 来源:发表于2020-04-03 12:29 被阅读0次
columnList: 列 
valueList:值
tablename:表名

int batchSaveList(@Param("columnkey") List<String> columnList,@Param("columnvalue") List<List<String>> valueList,@Param("tableName") String tablename);

<insert id="batchSaveList" parameterType="java.util.HashMap">
      insert into ${tableName} 
      <foreach item='item' index='index' collection='columnkey' open='(' separator=',' close=')'>
        ${item}
      </foreach> 
       values 
       <foreach item='colvalue' index='index' collection='columnvalue'  separator=',' close=';'>
           <foreach item='clv' index='index' collection='colvalue' open='(' separator=',' close=')'>
              #{clv}
           </foreach>
       </foreach>
  </insert>

相关文章

网友评论

      本文标题:mybatis 添加多条数据(动态 :表名,列名,值)

      本文链接:https://www.haomeiwen.com/subject/trlhphtx.html