ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jiming Liu" <jiming...@gmail.com>
Subject auto-generated keys in Oracle
Date Wed, 16 May 2007 10:27:36 GMT
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

Mime
View raw message