xml批量插入消息:
keyProperty ,默认值unset,用于设置getGeneratedKeys方法或selectKey子元素返回值将赋值到领域模型的哪个属性中
resultType ,keyPropety所指向的属性类全限定类名或类型别名
order属性 ,取值范围BEFORE|AFTER,指定是在insert语句前还是后执行selectKey操作
statementType ,取值范围STATEMENT,PREPARED(默认值),CALLABLE
1.传参
<insert id="insertIdIn" parameterType="java.util.List">
<selectKey resultType="long" keyProperty="id" order="AFTER">
SELECT
LAST_INSERT_ID()
</selectKey>
insert into notification (user_id, notification_name)
values
<foreach collection="idList" item="userId" index="index" separator=",">
( #{userId}, "XXXX")
</foreach>
</insert>
2.别的表中的数据
INSERT INTO TStudent(name,age)
<foreach collection="list" item="item" index="index" open="(" close=")" separator="union all">
SELECT #{item.name} as a, #{item.age} as b FROM DUAL
</foreach>