mybatis oracle中使用uuid作主键

<insert id="insert" parameterType="com.xxx.SystemDepartment">
    <selectKey keyProperty="id" resultType="String" order="BEFORE">
        select sys_guid() from dual
    </selectKey>
    insert into SYSTEM_DEPARTMENT (ID,DEPNAME, SUPERID, SORT, STATE)
    values ( #{id,jdbcType=VARCHAR},#{depname,jdbcType=VARCHAR},
    #{superid,jdbcType=DECIMAL}, #{sort,jdbcType=DECIMAL},
    #{state,jdbcType=DECIMAL})
</insert>

sys_guid函数,是oracle生成uuid的函数,keyProperty="id"就是对应你的对象的属性。

猜你喜欢

转载自blog.csdn.net/qq_30270931/article/details/80021212