<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