7.0Mybatis在insert之后,返回想要的字段值

一.如题

<insert id="insert" parameterType="cn.firstpro.pojo.Shipping" useGeneratedKeys="true" keyProperty="id">
    insert into first_shipping (id, user_id, receiver_name, 
      receiver_phone, receiver_mobile, receiver_province, 
      receiver_city, receiver_district, receiver_address, 
      receiver_zip, create_time, update_time
      )
    values (#{id,jdbcType=INTEGER}, #{userId,jdbcType=INTEGER}, #{receiverName,jdbcType=VARCHAR}, 
      #{receiverPhone,jdbcType=VARCHAR}, #{receiverMobile,jdbcType=VARCHAR}, #{receiverProvince,jdbcType=VARCHAR}, 
      #{receiverCity,jdbcType=VARCHAR}, #{receiverDistrict,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR}, 
      #{receiverZip,jdbcType=VARCHAR}, now(), now()
      )
  </insert>

useGeneratedKeys="true" keyProperty="id" 在insert之后,这个id就会填充到参数的shipping中的id上.

展开阅读全文

没有更多推荐了,返回首页