If the Entity being created doesn't have its own natural unique (e.g. Social
Security Number for a Person), then a key generation facility is needed.
There are several viable approaches including:
- Using the databases sequence number generation facilities (vendor
specific).
- Using a service that generates unique keys based on some algorithm. There
are various approaches to this. One is to use a UUID algorithm like DCE's.
This topic is covered fairly well in the archvices.
-Chris.
> -----Original Message-----
> From: Lars Hagrot [SMTP:[EMAIL PROTECTED]]
> Sent: Tuesday, April 25, 2000 2:23 PM
> To: [EMAIL PROTECTED]
> Subject: Who is generating the key when you are using CMP?
>
> When you build a real system ( not a tutorial) you will recognize the
> problem below.
>
> If you have an Entity Bean and use CMP there must always be a unique
> key. Where does it come from?
>
> 1) from the "user" (and passed as parameter to the create method)?
> 2) from the EJB-Container or some Session bean (how does it know it is
> unique)?
> 3) from the database ( for example "max(col)" or "identity")?
>
> In 1) and 2) you can assign the key in the create method.
> But in 3) you must do a query or insert a row to get the key but how
> can I tell the Container do do that. I am supposed to assign the key in
> the create method.
>
> Is there any standards for this problem?
> Does this imply that example 3) must be implemented as BMP?
>
> What is the best solution if it has to be scalable and shall work with
> cluster of EJB-Servers?
>
> Regards
>
> Lars Hagrot
>
> --
> Lars Hagrot E-mail: [EMAIL PROTECTED]
> Object Technology Mentoring Phone: +46 8 50714409
> Enea Data AB Fax: +46 8 658 57 90
> Hornsgatan 166
> S-117 28 Stockholm
> Sweden
>
> ==========================================================================
> =
> 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".