Welcome 微信登录

首页 / 数据库 / MySQL / MyBatis插入时候获取自增主键方法

MyBatis 3.2.6插入时候获取自增主键方法有二以MySQL5.5为例:方法1:    <insert id="insert" parameterType="Person" useGeneratedKeys="true" keyProperty="id">
        insert into person(name,pswd) values(#{name},#{pswd})
    </insert>方法2:    <insert id="insert" parameterType="Person">
        <selectKey keyProperty="id" resultType="long">
            select LAST_INSERT_ID()
        </selectKey>
        insert into person(name,pswd) values(#{name},#{pswd})
    </insert>插入前实体id属性为0;插入后实体id属性为保存后自增的id;ORA-20079: full resync from primary database is not doneORA-27300,ORA-27301,ORA-27302相关资讯      MyBatis主键自增  MyBatis主键  本文评论 查看全部评论 (0)
表情: 姓名: 字数