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属性方法来获取了

猜你喜欢

转载自www.cnblogs.com/ampl/p/9461170.html