批量删除
<delete id="deleteById" parameterType="java.util.List">
delete from 表名 where HOS_ID in
<foreach collection="list" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
批量插入
<insert id="insertUser" parameterType="java.util.List">
insert into 表名
(
ID,
NAME
)
<foreach collection="list" item="item" index="index" open="(" close=")" separator="union all">
SELECT
#{item.id},
#{item.name}
from dual
</foreach>
</insert>
插入输入返回主键 (主键会注入到Print 类对应的属性上)
<insert id="insertPrint" parameterType="Print">
<!-- 序列返回主键 -->
<selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
SELECT SEQ_ID.Nextval as id from DUAL
</selectKey>
insert into 表名
(
ID,
NAME
)
values
(
#{id},
#{name}
)
</insert>