mybatis-plus 获取新增id

<insert id="insert" parameterType="com.xxx.xxxx.pojo.User">
        insert into t_user (name) 
        values (#{user.name})
        <selectKey resultType="Integer" order="AFTER" keyProperty="user.userId">
            SELECT LAST_INSERT_ID() AS userId
        </selectKey>
</insert>

第二种方法

<insert id="insert" parameterType="Spares"     
        useGeneratedKeys="true" keyProperty="id">    
        insert into system(name) values(#{name})    
</insert>

然后在调用的时候就可以用对象的get属性方法来获取了

posted @ 2018-08-11 21:30  litf  阅读(24004)  评论(0)    收藏  举报