62,614
社区成员
发帖
与我相关
我的任务
分享
public class TrainRecord implements Serializable {
private static final long serialVersionUID = -1206960462117924923L;
private long id;
private long activityId;
private long empId;
private int flag;
private String addTime;
//setter and getter
}
对应的mapper.xml中定义如下:
Xml代码
<resultMap type="TrainRecord" id="trainRecordResultMap">
<id column="id" property="id" jdbcType="BIGINT" />
<result column="add_time" property="addTime" jdbcType="VARCHAR" />
<result column="emp_id" property="empId" jdbcType="BIGINT" />
<result column="activity_id" property="activityId" jdbcType="BIGINT" />
<result column="flag" property="status" jdbcType="VARCHAR" />
</resultMap>
mapper.xml中批量插入方法的定义如下:
<insert id="addTrainRecordBatch" useGeneratedKeys="true" parameterType="java.util.List">
<selectKey resultType="long" keyProperty="id" order="AFTER">
SELECT
LAST_INSERT_ID()
</selectKey>
insert into t_train_record (add_time,emp_id,activity_id,flag)
values
<foreach collection="list" item="item" index="index" separator="," >
(#{item.addTime},#{item.empId},#{item.activityId},#{item.flag})
</foreach>
</insert>