1. 程式人生 > >mybatis 插入一條記錄 參數為map的寫法

mybatis 插入一條記錄 參數為map的寫法

map rtu dex obj word pan batch doc span

xml:

    <insert id="insertUser" parameterType="java.util.Map">
        insert into user (
        id,
        <foreach collection="columnMap" item="value" index="key" separator=",">
            ${key}
        </foreach>
        )
        values (
        SEQ_USER.NEXTVAL,
        
<foreach collection="columnMap" item="value" index="key" separator=","> #{value} </foreach> ) </insert>

代碼:

            Map<String, Object> columnMap = new HashMap<>();
            columnMap.put("name", "xiaoming");
            columnMap.put(
"password", "123"); columnMap.put("columnMap", columnMap); userService.insertProvBatchDoc(columnMap);

mybatis 插入一條記錄 參數為map的寫法