1. 程式人生 > >mybatis插入數據後返回自增的主鍵id

mybatis插入數據後返回自增的主鍵id

pre tails isp entity CA ctc ron creat rod

在插入數據時候想自動返回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