mybatis主键回显

来源:互联网 发布:特朗普越南知乎 编辑:程序博客网 时间:2024/05/18 13:42
 <insert id="insert" parameterType="cn.e3mall.pojo.TbContentCategory" >  <selectKey keyProperty="id" resultType="long" order="AFTER">    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>

其中:

Mysql获取下个自增ID select last_insert_id()

order="AFTER" 在插入之后生成