mybatis插入数据后返回自增的主键id

Posted 小虾米的java梦

tags:

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

在插入数据时候想自动返回mysql的自增的主键,需要在mapper.xml中配置下;

<insert id="insert" parameterType="com.rograndec.wdzs.admin.data.wdzs.entity.ProductCategoryEntity" useGeneratedKeys="true" keyProperty="id" >
insert into product_category (id, parent_id, cate_name,
sort_order, is_parent, created_at,
updated_at)
values (#{id,jdbcType=INTEGER}, #{parentId,jdbcType=INTEGER}, #{cateName,jdbcType=VARCHAR},
#{sortOrder,jdbcType=INTEGER}, #{isParent,jdbcType=BIT}, now(),
now())
</insert>
相关链接:

https://blog.csdn.net/sinat_30474567/article/details/51395247













以上是关于mybatis插入数据后返回自增的主键id的主要内容,如果未能解决你的问题,请参考以下文章