ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Hodge" <dyho...@gmail.com>
Subject Re: Obtaining Generated Primary Keys
Date Fri, 15 Sep 2006 14:22:10 GMT
That makes sense.  However, I am concerned with possible concurrency
issues.  If two inserts occur at the same time we can't guarantee the select
key would work.  Is this a valid concern with selectKey solution you
mentioned?

Thanks,

David Y. Hodge

On 9/15/06, Larry Meadors <lmeadors@apache.org> wrote:
>
> David,
>
> You can still use the selectKey element in your insert if you have
> some way (other than the generated key) of uniquely identifying the
> inserted data.
>
> <insert ...>
>   insert into blah blah blah
>   <selectKey property="yourIdPropertyName" ...>
>     select your_id from blah blah blah
>   </selectKey>
> </insert>
>
> Then as long as you call insert() it should work.
>
> Larry
>
>
> On 9/15/06, David Hodge <dyhodge@gmail.com> wrote:
> > I am using Oracle and I am wondering if there is a way to obtain a
> trigger
> > generated Primary key after doing an INSERT with iBatis.
> >
> > I know there is a selectKey function but that seems to work only if you
> have
> > a select statement, which makes sense.  Other databases have ways
> > for you to select the last_generated_id() but I do not think Oracle has
> this
> > capability.
> >
> > Has anyone else had this problem or know of a work around?
> >
> >
> > Thanks,
> >
> > David Y. Hodge
> >
>

Mime
View raw message