【ibatis】IBatis的SQL批量操作
1、Ibatis批量添加(传入class的list即可)
<insert id="Add" resultMap="Select" parameterClass="list"> insert all <iterate conjunction=""> into SYS_TABLE (id,Category,Name,Code,Status) values(#[].Id#,#[].Category#,#[].Name#, #[].Code#,#[].Status#) </iterate> <!--下面这句必须加,不然会提示找不到SELECT--> select * from dual </insert>
2、Ibatis批量删除(传入ID字符串的list即可)
<delete id="Del" resultMap="Select" parameterClass="list"> delete from SYS_TABLE where id in <iterate conjunction="," open="(" close=")"> #[]# </iterate> </delete>
3、Ibatis批量修改(传入class的list即可)
<update id="Update" resultMap="Select" parameterClass="list"> begin <iterate conjunction=""> update SYS_TABLE set Category=#[].Category#, Name =#[].Name#, Code =#[].Code#, Status =#[].Status# where id = #[].Id#; </iterate> end; </update>
4、Ibatis查询
获取列表跟删除一样,遍历ID的list