ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sundar Sankar" <fatboys...@gmail.com>
Subject Re: How to get the generated key from insert with Oracle
Date Fri, 09 May 2008 17:59:56 GMT
Hi,
     When using Hibernate, I have tested the same using rolling back one
session and committing the second one and vice versa. If you observe, The
value u get after the transaction is over will be greater than both the
sequence Id's. That is, if first ones id is X and seconds is X+1, no matter
which transaction got rolled back, a third person accessing would always get
back X+2, even if X or X+1 was available. I am not sure if this is something
hibernate does, but it would be a good way to test The concurrency issue in
the application.

My $0.002

-Sundar

On Fri, May 9, 2008 at 8:08 AM, Chris O'Connell <oconnell@gorillachicago.com>
wrote:

> Argh... sometimes it is that easy.
>
> Yep, two different sql plus sessions, the first will always get *it's*
> correct value of sequence.currval, regardless of how many times another
> session calls sequence.nextval.
>
> Thanks,
> Chris
>
> -----Original Message-----
> From: Clinton Begin [mailto:clinton.begin@gmail.com]
> Sent: Friday, May 09, 2008 9:43 AM
> To: user-java@ibatis.apache.org
> Subject: Re: How to get the generated key from insert with Oracle
>
> Easy enough to test... open two sqlplus sessions and step through an
> example...
>
>
> Clinton
>
> On Fri, May 9, 2008 at 8:12 AM, Chris O'Connell
> <oconnell@gorillachicago.com> wrote:
> > Thanks.  I had never heard this before.  Just to make sure we are talking
> > about the same thing, I'm not concerned about the sequence returning the
> > same value to two different people when the trigger is calling 'nextval'.
> > I'm worried about the fact that two inserts could happen before my code
> that
> > tries to call "sequence.currvalue" can execute for the first insert and I
> > end up with two difference insert actions that get the same value for
> > "sequence.currvalue".
> >
> > It isn't that I don't believe you :) but this is counter to what I
> *thought*
> > I knew, so I'm trying to get a full understanding of what is going on.
> >
> > Thanks,
> > Chris
> >
> > -----Original Message-----
> > From: Larry Meadors [mailto:larry.meadors@gmail.com]
> > Sent: Thursday, May 08, 2008 5:38 PM
> > To: user-java@ibatis.apache.org
> > Subject: Re: How to get the generated key from insert with Oracle
> >
> > Not with a sequence, I've been told that they are 'session' aware, so
> > if you get id 123 in your session, no one else ever will.
> >
> > Larry
> >
> >
> > On Thu, May 8, 2008 at 4:21 PM, Chris O'Connell
> > <oconnell@gorillachicago.com> wrote:
> >> Even if I am executing all of this inside a transaction, don't I still
> > have
> >>  concurrency issues with this approach?
> >>
> >>
> >>
> >>  -----Original Message-----
> >>  From: Larry Meadors [mailto:larry.meadors@gmail.com]
> >>  Sent: Thursday, May 08, 2008 5:12 PM
> >>  To: user-java@ibatis.apache.org
> >>  Subject: Re: How to get the generated key from insert with Oracle
> >>
> >>  I think this would be the preferred SQL for that:
> >>
> >>  select ids.currval from dual
> >>
> >>  ...where ids is your sequence's name.
> >>
> >>  Larry
> >>  No virus found in this incoming message.
> >>  Checked by AVG.
> >>  Version: 8.0.100 / Virus Database: 269.23.10/1421 - Release Date:
> > 5/7/2008
> >>  5:23 PM
> >>
> >>
> > No virus found in this incoming message.
> > Checked by AVG.
> > Version: 8.0.100 / Virus Database: 269.23.10/1421 - Release Date:
> 5/7/2008
> > 5:23 PM
> >
> >
> No virus found in this incoming message.
> Checked by AVG.
> Version: 8.0.100 / Virus Database: 269.23.14/1425 - Release Date: 5/9/2008
> 12:38 PM
>
>

Mime
View raw message