mapper返回自动生成的主键,参见红色部分配置。
<insert id="insert" parameterType="cn.niter.forum.model.Article">
<selectKey keyProperty="id" resultType="Long" order="AFTER">
select last_insert_id()
</selectKey>
insert into article (id, title, description,
html, markdown, article_type,
source, link, pub_date
)
values (#{id,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR},
#{html,jdbcType=VARCHAR}, #{markdown,jdbcType=VARCHAR}, #{articleType,jdbcType=INTEGER},
#{source,jdbcType=VARCHAR}, #{link,jdbcType=VARCHAR}, #{pubDate,jdbcType=VARCHAR}
)
</insert>