mybatis全動態批量插入list >


動態批量插入有幾個問題

1表名動態自定義

2列動態自定義

3批量

<insert id="insertTableListDynamic" parameterType="java.util.HashMap">
        insert into
        ${map.tableName}
        (
        <foreach collection="map.mapHead" index="key" item="value"
                 separator=",">
            `${key}`
        </foreach>
        )
        values
        <foreach collection="map.list" item="line" separator=",">
            (
            <foreach collection="line" index="key" item="value"
                     separator=",">
                #{value}
            </foreach>
            )
        </foreach>
    </insert>

  java代碼:

private void insertBatchList(String tableName,Map<String, Object> mapHead,List<Map<String, Object>> list){
        Map<String, Object> batchList = new HashMap<>();
        batchList.put("tableName", tableName);
        batchList.put("mapHead",mapHead);
        batchList.put("list",list);
        insertTableListDynamic(batchList);
    }

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM