You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Jiming Liu <ji...@gmail.com> on 2007/05/16 12:27:36 UTC
auto-generated keys in Oracle
hi guys,
I was trying to use auto-generated key in oracle by iBatis. But it just do
not work. I used the feature in Mysql, it works. Is it a bug of iBatis
2.3.0.677?
here is my iBatis config part
<insert id="insertMake" parameterClass="com.jiming.Foo">
<selectKey resultClass="int" type="pre">
SELECT SEQ_FOO.NEXTVAL AS ID FROM DUAL
</selectKey>
INSERT INTO foo (id, name) VALUES(#id#, #name#)
</insert>
It cannot set the NEXTVAL to the id property in Foo class, which cause
duplicated PK error(ORA-00001). Is ther anything I used wrong or it is a
bug?
Now, i can only use INSERT INTO foo (id, name) VALUES(SEQ_FOO.NEXTVAL,
#name#), and it works. But i do need get the id after the record inserted.
Any suggestiong please?
Great thanks!
Jiming