Answer below...
[ some things deleted...]
> >
> > On a slightly different subject, how are people dealing with getting
> unique
> > key values when they insert records using entity beans? We're trying to
> use
> > an entity bean with two fields (keyname and keyvalue). So when a business
> > service (held in a stateless session bean) requires a new key it makes a
> > call to the entity bean to get the next key value, analogous to Oracle
> > sequences. Does anyone have any views on this approach, will it work ??
> >
> > regards
> >
> >
> > Bhupesh Wagjiani
> > GamCom Solutions Limited
> > [EMAIL PROTECTED]
> >
> >
This won't work if there are multiple containers involved.
Here is one way I have found that works. Create a table on the database to
hold a key value. Then, create a stateless session bean with a method
(marked REQUIRES_NEW) that will give you a new primary key. Now, when you
need a primary key, the stateless session bean will go the database,
determine what key is next, increment the key on the db, and then give you
back the primary key. Since this is in a separate transaction, it won't
block while other work is going on.
To reduce the number of database accesses, have the stateless session
reserve a 'block' of keys at one time. Have the session give them out one
at a time, and only go to the database when you need more.
HTH
Jonathan Baker
Internet Applications Division
===========================================================================
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".