且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取mybatis中最后插入记录的ID

更新时间:2023-11-15 18:36:46

id被注入对象:

int num_of_record_inserted = fileAttachmentMapper.insertSelective(fileAttachment);

int id = fileAttachment.getId();

selectKey 做的是设置id在你要插入的对象中,在这种情况下在 fileAttachment 中的属性 id 并插入AFTER记录。

What selectKey does is to set the id in the object you are inserting, in this case in fileAttachment in its property id and AFTER record is inserted.