Use the keyProperty attribute of selectkey...
________________________________ From: Jiming Liu [mailto:[EMAIL PROTECTED] Sent: woensdag 16 mei 2007 12:28 To: [email protected] 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
