<insert id="insert" parameterType="com.pojo.TSubject" useGeneratedKeys="true" keyProperty="subjectid" >
insert into t_subject ( parentid, subjectname, subjecttype, subjectitem, subjectanser, displaytype) values ( #{parentid,jdbcType=INTEGER}, #{subjectname,jdbcType=VARCHAR}, #{subjecttype,jdbcType=VARCHAR}, #{subjectitem,jdbcType=VARCHAR}, #{subjectanser,jdbcType=VARCHAR}, #{displaytype,jdbcType=VARCHAR})
</insert>
useGeneratedKeys="true" keyProperty="subjectid"
“subjectid”表主键
subjectService.insert(tSubject);
插入成功后:tSubject..getSubjectid() 就可以得到刚刚插入记录主键id