No, I think it only runs one of them...but are you really generating two new keys?
If you are, don't do it this way unless it is and will always be a single threaded system, and only if your database can't do auto-incrementing ids - what database are you using? Larry On Wed, Sep 3, 2008 at 2:52 AM, PLC_David <[EMAIL PROTECTED]> wrote: > > Hello, > > i have a problem with an insert. > I need two generated ids to avoid an update after the insert. > > My Question is: Is it possible to use two selectKey Tags. > Ibatis throws no exception, instead I get the correct id at the first > selectKey and 0 at the second selectKey. > > > <insert id="insertCd" parameterClass="cd"> > <selectKey resultClass="int" keyProperty="id"> > SELECT COALESCE(max(ID)+1,1) from CD > </selectKey> > <selectKey resultClass="int" keyProperty="db.id"> > SELECT COALESCE(max(ID)+1,1) from DB > </selectKey>) > INSERT INTO .... (ID, DB_ID, ....) > VALUES (#id#, #db.id#, ...) > </insert> > -- > View this message in context: > http://www.nabble.com/selectKey-twice-tp19285322p19285322.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >
