首页 > 学院 > 开发设计 > 正文

mybatis插入oracle的序列号

2019-11-11 02:03:43
字体:
来源:转载
供稿:网友

使用Oracle的序列号

先查询出下一个序列号,且会自动注入到参数中的指定属性上(本例中的id属性), 插入完成后, controller中的user对象的id属性也有值了

	<insert id="addUser" parameterType="user" >		<!-- keyPRoperty: 将序列号设置到user对象中,且在controller中可以使用  -->		<selectKey keyProperty="id" order="BEFORE" resultType="string">			SELECT seq_changez_user.nextval id from dual		</selectKey>		insert into temp_changez_user (id, username) values(#{id}, #{username})	</insert>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表