你好.我想请问一下如何在MyBatis中获取Oracle中自动增长的主键
<insertid="insertIndent"parameterType="Indent.entity.Indent"><selectKeyresultType="in...
<insert id="insertIndent" parameterType="Indent.entity.Indent">
<selectKey resultType="int" keyProperty="indentid" order="AFTER">
SELECT indent_id.NEXTVAL FROM DUAL
</selectKey>
insert into indent (indentid,name,address,createtime)values(indent_id.NEXTVAL.#{name},#{address},sysdate)
</insert> 展开
<selectKey resultType="int" keyProperty="indentid" order="AFTER">
SELECT indent_id.NEXTVAL FROM DUAL
</selectKey>
insert into indent (indentid,name,address,createtime)values(indent_id.NEXTVAL.#{name},#{address},sysdate)
</insert> 展开
1个回答
展开全部
我们项目组正好用到了这个,SEQ_ZONE为sequence,则mybatis配置文件如下:
<insert id="save" parameterType="com.threeti.to.ZoneTO" >
<selectKey resultType="java.lang.Long" keyProperty="id" order="AFTER" >
SELECT SEQ_ZONE.CURRVAL AS id from dual
</selectKey>
insert into TBL_ZONE (ID, NAME
)
values (SEQ_ZONE.NEXTVAL, #{name,jdbcType=VARCHAR}
)
</insert>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询