MyBatis配置
这是mysql的配置,注意需要加上&allowMultiQueries=true配置
jdbc_url=jdbc:mysql://localhost:3306/go?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
批量更新
<update id="batchUpdate"> <foreach collection="list" separator=";" item="info"> UPDATE template <set> update_date = #{info.updateDate}, title = #{info.title}, content = #{info.content}, sort = #{info.sort}, sign = #{info.sign}, business_id = #{info.businessId} </set> WHERE id = #{info.id} </foreach> </update>
批量添加
<insert id="batchInsert"> INSERT INTO template( id, create_date, create_by, update_date, title, content, sort, sign, business_id ) VALUES <foreach collection ="list" item="info" separator =","> ( #{info.id}, #{info.createDate}, #{info.createBy.id}, #{info.updateDate}, #{info.title}, #{info.content}, #{info.sort}, #{info.sign}, #{info.businessId} ) </foreach > </insert>