There are many posts in the list's archives on this topic. If you use a
service approach to generating UIDs, you need to m ake sure that the service
either a singleton, synchronizes around a data source, or uses an algorithm
that gaurantees uniqueness even when the service is not a singleton...

-Chris.

> -----Original Message-----
> From: Tim Endres [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, January 12, 2000 12:13 PM
> To:   [EMAIL PROTECTED]
> Subject:      Re: Primary Key Generation
>
> > One way I can think of is to query oracle for the next key in the
> table's
> > sequence prior to .creating() my entity bean but that seems like a great
> > overhead given that I would need to go to the database twice for every
> > insert I do (one to get the key, and one to insert it).
> >
> > Another way would be to ask oracle for a key as a starting point and
> then
> > increase it until I have done all my inserts (for a transaction?) and
> then
> > tell oracle the new value for the sequence. This may be more efficient
> but I
> > am not sure how safe it is given that while I am increasing my sequence
> some
> > other process may query oracle for the next key (in which case we would
> both
> > use the same).
>
> You will need to generate the keys. Using a table to manage them is the
> way
> to go. For efficiency's sake, I use a stateless session to hand out keys,
> and
> I can tell it I want "a dozen" keys and it reserves that "range". This
> prevents
> any contention issues.
>
> tim.
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to