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

2020-04-03  本文已影响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>
上一篇 下一篇

猜你喜欢

热点阅读