首页 > 代码库 > mybatis插入返回主键

mybatis插入返回主键

 useGeneratedKeys="true" keyProperty="id"

<insert id="insertReturnPrimaryKey" parameterType="com.haitao55.spider.order.robot.platform.dos.TaskHistoryDO" useGeneratedKeys="true" keyProperty="id">
insert into task_history(
task_id,
agent_id,
assign_time,
start_time,
end_time,
status,
ctime,
utime,
account_id,
address_id,
coupon_id
) values(
#{taskId},
#{agentId},
#{assignTime},
#{startTime},
#{endTime},
#{status},
#{createTime},
#{updateTime},
#{accountId},
#{addressId},
#{couponId}
)
</insert>

mybatis插入返回主键