mybatis 新增返回id

 <insert id="insert" parameterType="com.top.nhm.domain.entity.DistributorCompany" >


    <selectKey resultType="java.lang.Integer" order="AFTER" keyProperty="id">
      SELECT LAST_INSERT_ID() as id
      </selectKey>


    insert into tb_DistributorCompany (id,name, delFlag,
      cityId,name_short,address,remark)
    values (#{id,jdbcType=INTEGER},#{name,jdbcType=VARCHAR}, #{delflag,jdbcType=TINYINT},
      #{cityid,jdbcType=INTEGER},#{nameShort,jdbcType=VARCHAR},#{address,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR})
  </insert>

你可能感兴趣的:(mybatis)