需求插入A表后,获取到A表的自增id,然后作为外键插入B表。
<insert id="save" parameterType="com.score.subject.domain.SubjectDO"
useGeneratedKeys="true" keyProperty="id">
insert into score_subject(`content`) values (#{content})
</insert>
java
public int save(SubjectDO subject){
int count = subjectDao.save(subject);
//subject表的自增id
int subid = subject.getId();
}