Keep the selectKey after the statement for MySQL and other auto-increment style key generators. Only sequences like those supported by Oracle should come before the statement.
Also, a full stack trace might help. Clinton On Sat, Jan 23, 2010 at 3:20 PM, StevenF <ste...@web2.filipowicz.com> wrote: > > Hi Guys, > > Still no luck here. > > I have this, but doesn't work: > ---------------------------- > <statement id = "insertChesser" > parameterClass="nl.chessone40.domain.Chesser" > > <selectKey resultClass="int" keyProperty="chesserId"> > select last_insert_id() as value > </selectKey> > INSERT INTO Chesser > (login, > password, > firstName, > lastName, > credits) > values > (#login#, > #password#, > #firstName#, > #lastName#, > #credits#) > </statement> > ---------------------------- > > Also tried: > ---------------------------- > <insert id = "insertChesser" > parameterClass="nl.chessone40.domain.Chesser" > > <selectKey resultClass="int" keyProperty="chesserId"> > select last_insert_id() as value > </selectKey> > INSERT INTO Chesser > (login, > password, > firstName, > lastName, > credits) > values > (#login#, > #password#, > #firstName#, > #lastName#, > #credits#) > </insert > > --------------------------- > > This gives an error: > SqlMapClient operation; uncategorized SQLException for SQL []; SQL state > [null]; error code [0]; Insert statements cannot be executed as a query.; > nested exception is java.sql.SQLException: Insert statements cannot be > executed as a query. > > What is the difference between <statement id="...> and <insert id="...> ? > > Thanks for the help!! > > > Niels Beekman-2 wrote: > > > > Your XML is simply invalid, use an editor that supports DTD validation. > > The selectKey element can only be used inside select elements. > > > > I also think that resultClass="java.lang.Long" is obsolete, and should > > be removed. > > > > Niels > > > > > > > > -- > View this message in context: > http://old.nabble.com/insert-going-wrong-after-going-from-Sybase-to-MySQL-tp27274795p27290482.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > For additional commands, e-mail: user-java-h...@ibatis.apache.org > >