That should be fine... but that's a different questions. :-) Better yet, if you use selectKey, it will even set the ID property on the JavaBean for you.
Clinton On Wed, May 20, 2009 at 2:02 PM, m.montano <[email protected]> wrote: > > is there any mismatch in your opinion if I substitute the > set @id_a = cast(IDENT_CURRENT('file') + ident_incr('file') as varchar) > with an ibatis select? > is the transaction still valid? > I mean something like > > //begin transaction > sqlMap.startTransaction(); > > //int idAudio = 000;//to retrieve + increment ...how? > int idAudio= sqlMap.select("selectLastIdAudio"); > amdr.setIdAudio(idAudio ); > sqlMap.insert("insertFileMD", amdr); > ann.setIdAudio(idAudio ); > sqlMap.insert("insertAnnuncio", ann); > > sqlMap.commitTransaction(); > //commit transaction > > > > > Clinton Begin wrote: > > > > You're better off with JDBC then. There's too much of a mismatch for > this > > SQL. It might not be impossible, but it certainly wouldn't be easy. > > Try it out, but if iBATIS is a hammer, this isn't a nail... > > > > Clinton > > > > On Wed, May 20, 2009 at 1:53 PM, m.montano <[email protected]> wrote: > > > >> > >> I can't use a stored procedure because I can't change the database. > >> I have to get the code (begin transaction...go) working with ibatis > >> syntax... isn't it possible? I've read te documentation but I don't > >> understand how can I retrieve the identity in the same way like the sql > >> syntax. > >> > >> Michela > >> > >> > >> > >> Clinton Begin wrote: > >> > > >> > Not sure where to start with this one, but you might want to read the > >> > entire > >> > user guide. > >> > * You shouldn't start the transaction in your statement > >> > * Look up <selectKey> specifically in the docs > >> > * This looks like a proc body, so you might want to look up stored > >> proc > >> > support > >> > * In this case, it might be necessary to return it as an output > >> > parameter > >> > > >> > You'll have to play with it to see what works best for you. > >> > > >> > Clinton > >> > > >> > On Wed, May 20, 2009 at 1:25 PM, m.montano <[email protected]> > wrote: > >> > > >> >> > >> >> Hi all, i'm a newbie in ibatis... I'm working on MS sql server 2000, > >> >> driver > >> >> jtds. > >> >> The problem is: I have this transaction to execute > >> >> > >> >> begin transaction > >> >> declare @id_audio varchar(20) > >> >> set @id_a = cast(IDENT_CURRENT('file') + ident_incr('file') as > >> varchar) > >> >> INSERT INTO FILEMD (furl, F1, F2, IDA) > >> >> VALUES ('val furl', 'val f1', 'val f2', @id_a) > >> >> INSERT INTO ANNUNCI (idann, F3, F4, ida) > >> >> VALUES ('val idann', 'val f3', 'valore f4', @id_a) > >> >> commit transaction > >> >> GO > >> >> > >> >> I'm trying with: > >> >> //begin transaction > >> >> sqlMap.startTransaction(); > >> >> > >> >> int idAudio = 000;//to retrieve + increment ...how? > >> >> > >> >> amdr.setIdAudio(idAudio ); > >> >> sqlMap.insert("insertFileMD", amdr); > >> >> ann.setIdAudio(idAudio ); > >> >> sqlMap.insert("insertAnnuncio", ann); > >> >> > >> >> sqlMap.commitTransaction(); > >> >> //commit transaction > >> >> > >> >> > >> >> I'm not sure how to retrieve the idAudio (the identity column in > >> >> FILEMD)... > >> >> can please you help me? > >> >> thanx for support, > >> >> have a nice day, > >> >> Michela > >> >> -- > >> >> View this message in context: > >> >> http://www.nabble.com/Help-with-identity-tp23641858p23641858.html > >> >> Sent from the iBATIS - User - Java mailing list archive at > Nabble.com. > >> >> > >> >> > >> > > >> > > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/Help-with-identity-tp23641858p23642321.html > >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/Help-with-identity-tp23641858p23642456.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >
