mybatis

Mybatis

一、自增主键回显与非自增主键回显
1、自增主键回显(案例)
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
  insert into test.user(name, password, sex, age)
  values (#{name}, #{password}, #{sex}, #{age})
</insert>
2、非自增主键回显(案例)
<insert id="insert">
   <selectKey keyProperty="id"  keyColumn="id" order="BEFORE" resultType="java.lang.Integer">
      select max(id)+1 from user
   </selectKey>
  insert into test.user(id,name, password, sex, age)
  values (#{id},#{name}, #{password}, #{sex}, #{age})
</insert>
posted @ 2020-04-21 10:23  pipigang  阅读(100)  评论(0)    收藏  举报