1.mybatis+mysql自动生成uuid主键
<insert id="insert" parameterType="com.jo.model.Functions" >
<selectKey keyProperty="pkGlobalId" resultType="String" order="BEFORE">
select replace(uuid(),'-','') from dual
</selectKey>
insert into tbl_function (pk_global_id, name, parent_id,
sort, url)
values (#{pkGlobalId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{parentId,jdbcType=VARCHAR},
#{sort,jdbcType=INTEGER}, #{url,jdbcType=VARCHAR})
</insert>
在数据库中运行SQL
另外可以参考博客:https://blog.csdn.net/kongkongyanan/article/details/86096657
2.mybatis+oracle 生成uuid
<selectKey resultType="java.lang.String" keyProperty="comId" order="BEFORE">
select sys_guid() from dual
</selectKey>
在不同的项目中我是使用这两种方法生成的uuid,如有不足,欢迎指正!