mybatis主键自动生成策略

mybatis主键自动生成策略


    <insert id="save" parameterType="user" >

        <selectKey keyProperty="id" resultType="string" order="BEFORE">
            select uuid();
        selectKey>
        insert into user values(#{id},#{username},#{password})
    insert>

    <insert id="insertUser" parameterType="user">
        <selectKey keyProperty="id" keyColumn="id" resultType="integer">
            select last_insert_id();
        selectKey>
        insert into user value(#{id},#{username},#{password})
    insert>

    <insert id="insert" parameterType="user" useGeneratedKeys="true" keyProperty="id">
         insert into user value(#{id},#{username},#{password})
    insert>

你可能感兴趣的:(mybatis,mybatis)