NOTE:

Although using compound keys (custom primary keys) is legal in EJB 1.1 (even for
single fields), a bug in the J2EE RI prevents them from being used.  I figured it was
worth mentioning since people depended on the J2EE RI for developing beans.  In the
J2EE RI you can only use single-field primary keys.

Richard
--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition
Published by O'Reilly & Associates
http://www.EjbNow.com

Vlada Matena wrote:

> The primary key class MyPK defined below is legal in EJB 1.1. However,
> the "value" field must be defined as "public" in the class.
>
> Vlada
>
> ----- Original Message -----
> From: "Evan Ireland" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 25, 2000 3:25 PM
> Subject: Re: EJB spec does not permit numbers as primary keys
>
> > "Jonathan K. Weedon" wrote:
> > >
> > > c) Primary Key wrapper classes for single field primary
> > > keys are deprecated in EJB 1.1.  This precludes using a
> > > class FooPK as a primary key type.
> >
> > If this is deprecated (although I can see no evidence of it myself) then it
> > is a big mistake.
> >
> > I suspect that it is not deprecated. I would recommend the following pattern
> > for numeric primary keys:
> >
> > public class MyPK
> > {
> >     int value;
> >
> >     MyPK() { ... }
> >
> >     // hashCode and equals ...
> > }
> >
> > This is preferable to using java.lang.Integer as a primary key type as it gives
> > you better type safety (you can't accidentally pass an AccountKey where a
> > CustomerKey is expected).
> >
> > <vendor>
> > We also permit entity components to have non-valuetype primary keys in our
> > product, but the mechanism is proprietary and so we leave it undocumented.
> > </vendor>
> > ________________________________________________________________________________
> >
> > Evan Ireland              Sybase EAServer Engineering        [EMAIL PROTECTED]
> >                             Wellington, New Zealand               +64 4 934-5856
> >
> > ===========================================================================
> > 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".

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