mybatis獲得新增記錄的id值

有時候我們會遇到要獲得新增記錄的主鍵。如下。


1、在xxxMapper.xml中,如下位置加入藍框裏的語句



2、直接getter獲得。



附上代碼:

<selectKey resultType="java.lang.Integer" keyProperty="id">
select last_insert_id()
</selectKey>



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章