利用Mybatis 的 selectKey来获得:
或
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.edu.archive.business.domain.grade.pojo.model.ApplicationRecord" useGeneratedKeys="true">
insert into bj_application_record (parent_id, class_no, student_name,
kinsfolk_relation, `status`, refuse_remark,
create_time, update_time, version
)
values (#{parentId,jdbcType=INTEGER}, #{classNo,jdbcType=VARCHAR}, #{studentName,jdbcType=VARCHAR},
#{kinsfolkRelation,jdbcType=VARCHAR}, #{status,jdbcType=TINYINT}, #{refuseRemark,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{version,jdbcType=INTEGER}
)
</insert>
原文:https://www.cnblogs.com/tubashu/p/14755065.html