mybatis 主鍵UUID生成策略

<insert id="insert" parameterType="com.lsfwpt.lawmis.po.SysUser">
        <selectKey keyProperty="userId//你的主鍵屬性名" resultType="String" order="BEFORE">
            select replace(uuid(),'-','') from dual //原樣照抄 </selectKey>
        insert into sys_user (user_id, user_name, login_name,
        user_pwd)
        values (#{userId,jdbcType=VARCHAR}, #{userName,jdbcType=VARCHAR},
        #{loginName,jdbcType=VARCHAR},
        #{userPwd,jdbcType=VARCHAR})
    </insert>

在使用mybatis mapper.xml 進行接口實現的時候,使用UUID主鍵生成策略。mybatis

如上面代碼所示只需將 selectKey 標籤中的 keyProperty 更改成你的主鍵屬性名便可。app

相關文章
相關標籤/搜索