mybatis-plus多表操作的ID獲取


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>
復制代碼

第二種方法

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

然后在調用的時候就可以用對象的get屬性方法來獲取了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM