I have to admit, it is a very long post full of different views. :-) From what I 
gather, to avoid that situation, you
can use the high low pattern to prevent the same bean from ever having the same key.

-----Original Message-----
From: Jerson Chua [mailto:[EMAIL PROTECTED]]
Sent: Friday, September 08, 2000 9:39 AM
To: [EMAIL PROTECTED]
Subject: Re: Generating ID???


I've read it. But I'm particularly interested if this strategy works.

Jerson

--- "Bono, Chris" <[EMAIL PROTECTED]> wrote:
> Jerson,
> There is a long thread on this in the patterns section of serverside.com
>
> -----Original Message-----
> From: Jerson Chua [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 08, 2000 2:39 AM
> To: [EMAIL PROTECTED]
> Subject: Generating ID???
>
>
> Hello Guys...
>
> I've read an IBM article and it has an example in generating id/primary key. I have a
> doubt that 1 or more bean can get the same id. I want to verify this doubt. Is this
> scenario possible?
>
> 1. Customerbean1 retrieves max id
> 2. Customerbean2 retrieves max id
> 3. Customerbean1 increments maxid and store to db
> 4. Customerbean2 increments maxid and store to db
>
> public class CustomerEntityBean {
>         public void ejbCreate(String name, int type) {
>                 key = getNextKey();
>                 ...
>         }
>
>         protected long getNextKey() {
>                 long nextKey = 0;
>
>                 Customer newestCustomer = ((CustomerHome)
>                 entityContext.getEJBHome()).findNewest();
>                 // the implementation of findNewest is not shown,
>                 // i guess the findNewest returns the bean with the highest 
>id/primary
> key
>                 // in my point of view this is like select max(id) from customer + 1
>                 nextKey = ((CustomerKey)newestCustomer.getPrimaryKey()).key + 1;
>                 return nextKey;
>         }
> }
>
> What's your opinion? Will this design work?
>
> Jerson
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Mail - Free email you can access from anywhere!
> http://mail.yahoo.com/
>
> ===========================================================================
> 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".
>


__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/

===========================================================================
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