设置主键自动生成UUID:
1 <insert id="add" useGeneratedKeys="true" parameterType="com.linyr.bean.Person"> 2 <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String"> 3 select UUID() 4 </selectKey> 5 insert into person(id,name,sex,age,address) 6 values(#{id},#{name},#{sex},#{age},#{address}) 7 </insert>
批量删除:
1 <delete id="delete" parameterType="java.util.Arrays" > 2 delete from person 3 where id in 4 <foreach item="item" index="index" collection="array" open="(" separator="*" close=")"> 5 #{item} 6 </foreach> 7 </delete>