mybatis 获取新增数据的主键

Posted 李梵

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis 获取新增数据的主键相关的知识,希望对你有一定的参考价值。

<insert id="insert" parameterType="com.mmall.pojo.Shipping" useGeneratedKeys="true" keyColumn="id">
insert into mmall_shipping (id, user_id, receiver_name,
receiver_phone, receiver_mobile, receiver_province,
receiver_city, receiver_district, receiver_address,
receiver_zip, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR},
#{receiverPhone,jdbcType=VARCHAR}, #{receiverMobile,jdbcType=VARCHAR}, #{receiverProvince,jdbcType=VARCHAR},
#{receiverCity,jdbcType=VARCHAR}, #{receiverDistrict,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR},
#{receiverZip,jdbcType=VARCHAR}, now(), now()
)
</insert>











以上是关于mybatis 获取新增数据的主键的主要内容,如果未能解决你的问题,请参考以下文章

mybatis如何获取oracle新插入数据记录的主键?

Mybatis里Mapper映射sql文件里insert的主键返回selectKey使用

mybatis新增主键的返回值

mybatis生成UUID主键,且获取当前新增的UUID主键

mybatis新增数据时获取自增id

Mybatis 怎么返回insert插入的主键