You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Javier Leyba <xl...@gmail.com> on 2006/10/24 09:06:22 UTC

Re: selectKey problem

On 10/23/06, Larry Meadors <lm...@apache.org> wrote:
> That message looks iffy at best - I'd try w/o the resultClass on the
> the <insert> element. It should not needed in any case...same with the
> type attribute, but you should probably set the keyProperty attribute
> on the <selectKey> element.
>
> So..something like this:
>
> <insert id="insertNotification" parameterMap="insertNotificationParam">
>   insert into blah...
>   <selectKey resultClass="long" keyProperty="yourIdPropName">
>     SELECT LAST_INSERT_ID() AS value;
>   </selectKey>
> </insert>
>


Thanks for your reply.

I´ll not use generated id in the whole insert, I need to use it in my
code in other inserts that dependes of this.

Then:

1 - Could I avoid to keep keyProperty property ?

2 - Should the insert return my generated id ?

Thanks in advance

J

Re: selectKey problem

Posted by Larry Meadors <lm...@apache.org>.
I am not 100% sure I understand the question...but yes, I think if you
omit the keyProperty attribute, it will work like you want. The insert
method should return the generated key.

Larry


On 10/24/06, Javier Leyba <xl...@gmail.com> wrote:
> On 10/23/06, Larry Meadors <lm...@apache.org> wrote:
> > That message looks iffy at best - I'd try w/o the resultClass on the
> > the <insert> element. It should not needed in any case...same with the
> > type attribute, but you should probably set the keyProperty attribute
> > on the <selectKey> element.
> >
> > So..something like this:
> >
> > <insert id="insertNotification" parameterMap="insertNotificationParam">
> >   insert into blah...
> >   <selectKey resultClass="long" keyProperty="yourIdPropName">
> >     SELECT LAST_INSERT_ID() AS value;
> >   </selectKey>
> > </insert>
> >
>
>
> Thanks for your reply.
>
> I´ll not use generated id in the whole insert, I need to use it in my
> code in other inserts that dependes of this.
>
> Then:
>
> 1 - Could I avoid to keep keyProperty property ?
>
> 2 - Should the insert return my generated id ?
>
> Thanks in advance
>
> J
>