ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: auto-generated keys in Oracle
Date Wed, 16 May 2007 11:08:26 GMT
Use the keyProperty attribute of selectkey...

 

________________________________

From: Jiming Liu [mailto:jimingliu@gmail.com] 
Sent: woensdag 16 mei 2007 12:28
To: user-java@ibatis.apache.org
Subject: 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









Mime
View raw message