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".

Reply via email to