myBatis +mysql自动生成uuid主键

<insert id="insert" parameterType="com.mawulou.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>

猜你喜欢

转载自blog.csdn.net/zziamalei/article/details/45606259
今日推荐