mybatis 主键UUID生成策略

论坛 期权论坛 脚本     
匿名技术用户   2020-12-29 00:03   11   0

在使用mybatis mapper.xml 进行接口实现的时候,使用UUID主键生成策略。

如上面代码所示只需将 selectKey 标签中的 keyProperty 更改为你的主键属性名即可。

<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>

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP