mybatis access to the database is automatically generated primary key

<! - access to the database is automatically generated primary key ->

<insert id="xxxx" parameterType="xxxx" >
  <selectKey resultType ="java.lang.Long" keyProperty= "kid" order= "AFTER">
    SELECT LAST_INSERT_ID()
  </selectKey >
  insert into p_stock_check_detail (
    checkid,
    stockid,
  ) values
  <foreach collection ="list" item="msk" separator =",">
  (
    #{msk.checkid},
    #{msk.pid},
)
  </foreach >
</insert>

  

Guess you like

Origin www.cnblogs.com/DiiDii/p/11134044.html