mysql的myBatis,主键自增设置

Posted 波神

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql的myBatis,主键自增设置相关的知识,希望对你有一定的参考价值。

方法一:

insert id="insert" parameterType="Person" useGeneratedKeys="true" keyProperty="id">
        insert into person(name,pswd) values(#{name},#{pswd})
</insert> 

方法二:

<insert id="insert" parameterType="Person">
        <selectKey keyProperty="id" resultType="long">
            select LAST_INSERT_ID()
        </selectKey>
        insert into person(name,pswd) values(#{name},#{pswd})
</insert>

 

以上是关于mysql的myBatis,主键自增设置的主要内容,如果未能解决你的问题,请参考以下文章