mysql insert返回值插入后的id

方法1:

    <insert id="insert" parameterType="Person" useGeneratedKeys="true" keyProperty="id">
        insert into person(name,pswd) values(#{name},#{pswd})
    </insert>

 

方法2:

<insert id="insert" parameterType="com.xinrong.entity.member.DreamNexusDo" >
  <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
    SELECT LAST_INSERT_ID()
  </selectKey>
  insert into u_dream_nexus (UID, SUB_UID, CREATE_TIME, 
    START_TIME, END_TIME, REWARD_RATE
    )
          values (#{uid,jdbcType=INTEGER}, #{subUid,jdbcType=INTEGER}, #        {createTime,jdbcType=TIMESTAMP}, 
           #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #   {rewardRate,jdbcType=DECIMAL}
    )
</insert>

方法3: 

insert into addeditemgroup(addeditemgroupname) value('11') ; select @@IDENTITY  as id;

展开阅读全文

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