mybatis 批量insert list foreach里面的值有没有传递进来

如题所述

单个插入的时候使用selectKey 可以或得id,但是使用foreach做批量插入的时候,list中的对象的id始终是空的。
代码如下:

<insert id="insert" parameterType="list" useGeneratedKeys="true" keyProperty="id">
<selectKey resultType="int" keyProperty="id" order="AFTER">
SELECT LAST_INSERT_ID() as id;
</selectKey>
insert into product_room_price(
id,
room_id,
from_date,
to_date,
brfast,
base_price,
sale_price,
wee_price,
wee_price,
created_time,
update_time
温馨提示:答案为网友推荐,仅供参考