ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Grabowski <rongrabow...@yahoo.com>
Subject Re: selectKey for MySql
Date Wed, 02 Feb 2005 16:11:42 GMT
I've found that the column alias needs to match the property name:

<selectKey resultClass="java.lang.Integer"
keyProperty="criteriaConsistId" >
SELECT LAST_INSERT_ID() AS criteriaConsistId
</selectKey>

--- Clinton Begin <clinton.begin@gmail.com> wrote:

> "long" should work (convenient aliases).  Now, beyond that it is
> completely up to the driver to decide whether it's a legal mapping or
> not.  See, if your JDBC driver maps BIGINT to a BigInteger that's
> fine
> as a preferred type.  Most GOOD drivers will still allow you to call
> getLong() or getInt() and only throw an error if the value has gone
> beyond the legal range of long or int.  This is typical JDBC driver
> behaviour....something MySQL has never been very good at following.
> 
> One other thing you might want to try is aliasing the ...
> 
>  LAST_INSERT_ID() as ID
> 
> Or something like that.
> 
> Cheers,
> Clinton
> 
> On Wed, 2 Feb 2005 08:32:56 -0600, Brice Ruth <bdruth@gmail.com>
> wrote:
> > Should your resultClass be java.lang.Long instead of just "long" ?
> > 
> > 
> > On Wed, 2 Feb 2005 14:17:02 +0800, Gustavo Kuerten
> <rubycoder@gmail.com> wrote:
> > > The solution offered by Larry
> > >
>
http://www.mail-archive.com/ibatis-user-java@incubator.apache.org/msg00673.html
> > > does not work in my case. Anyone can offer any other insights on
> the
> > > problem ? In my case, my id is mapped to a BIGINT in the mysql
> > > database and is represented as a Long in the Java object. Is this
> > > mapping correct ?
> > >
> > >   <insert id="insertCurrency" parameterClass="currency">
> > >     insert into CURRENCY (VERSION, CURRENCY_CODE, COUNTRY)
> > >     values(NOW(), #currencyCode#, #country#)
> > >       <selectKey resultClass="long" keyProperty="id">
> > >         SELECT LAST_INSERT_ID()
> > >       </selectKey>
> > >   </insert>
> > >
> > > Thanks
> > >
> > > R
> > >
> >
> 


Mime
View raw message