时间:2021-07-01 10:21:17 帮助过:36人阅读
而oracle则不行,oracle主键自增长是通过sequence实现的,所以这种方式就不可以了,需要使用:
1.先通过sequence查出来id,再insert
<insert id=”add” useGeneratedKeys=”false” keyProperty=”id” parameterType=”Auth”>
<selectKey resultType=”String” keyProperty=”id” order=”BEFORE”>
select yoursequence.nextval as id from dual
</selectKey>
insert into s_user_auth (id,user_id, user_name) values(#{id},#{userid},#{username})
</insert>
2.直接insertsequence.nextval,如下
<insert id=”add” useGeneratedKeys=”false” keyProperty=”id” parameterType=”Auth”>
insert into s_user_auth (id,user_id, user_name) values(yoursequence.nextval,#{userid},#{username})
</insert>
mybatis配置oracle的主键自增长
标签: