mapper返回自动生成的主键

	<insert id="insert" parameterType="cn.e3mall.pojo.TbContentCategory" >
		//返回自动生成的主键
	    <selectKey keyProperty="id" resultType="Long" order="AFTER">   //after指的是执行sql语句后
	      select last_insert_id()
	    </selectKey>
	    
	    insert into tb_content_category (id, parent_id, name, 
	      status, sort_order, is_parent, 
	      created, updated)
	    values (#{id,jdbcType=BIGINT}, #{parentId,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, 
	      #{status,jdbcType=INTEGER}, #{sortOrder,jdbcType=INTEGER}, #{isParent,jdbcType=BIT}, 
	      #{created,jdbcType=TIMESTAMP}, #{updated,jdbcType=TIMESTAMP})
	  </insert>

猜你喜欢

转载自blog.csdn.net/weixin_42465206/article/details/88620500
今日推荐