Thanks a lot, that made me rethinking about it and now
I am using the generators from InterBase which seem to
be similar to sequences in Oracle.
Do you think it would be generate the ID implicitly with
a trigger or does it make sense to encapsulate this in
a bean method or even a dedicated EJB ?
Wei-ju
----- Original Message -----
From: "danch (Dan Christopherson)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 8:37 PM
Subject: Re: [JBoss-user] Auto-Incr
> Wei-ju Wu wrote:
>
> > Could you please explain me the difference between using an
> > AutoNumberBean and just doing a
> >
> > SELECT MAX(<id>) FROM <tablename> please ?
> >
>
>
> With an auto-number bean you can define it to be in its own transaction
> ('RequiresNew') and force a high isolation level (or use 'select ... for
> update' syntex) so that the row in question is locked but not for any
> longer than it takes to get the value and increment it.
>
> With the select max solution, you're either not locking the rows (which
> means that it's possible for two concurrent inserts to try to use the
> same PK value - bad) or your locking the entire table, causing all
> concurrent inserts to be serialized (which might happen anyway,
> depending on the database, that tables indexing style on its primary
> key, and probably a lot of other things)
>
>
> > I think these both approaches are similar and the above
> > one is the one I use. Is there a performance disadvantage
> > using a select max or can the database optimize the
> > access by using the index ? Or could there be conflicts
> > with the CMP ?
>
>
> The main issue is the concurrency.
>
> -danch
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user