It's at the bottom of page 159 of Richard Monson-Haefel's _Enterprise
Java Beans, 2nd Ed_:  "Although primary keys can be primitive wrappers
(Integer, Double, Long, etc.), primary keys cannot be primitive types
(int, double, long, etc.)"

I wasn't able to locate an explicit statement in the spec in my quick
scan, but the spec always refers to the primary key as the "primary key
class" and the deployment descriptor element is "prim-key-class".  This
is further reinforced by the comments in the DTD.

It makes sense, because EntityContext.getPrimaryKey() returns an Object.
Thus all PKs *must* be Objects.

About question #1:  I doubt there is any explicit requirement in the
spec that Integers be converted to ints in the database.  In fact, the
spec doesn't require a relational database; that's simply an
implementation detail.  Still, I doubt you will find *any* appservers
which serialize Integer keys as blobs - although it would work, the
performance penalty would be severe.

Jeff

>-----Original Message-----
>From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, March 01, 2001 1:22 AM
>To: Orion-Interest
>Subject: RE: Database schema type mappings
>
>
>Thanks for the reply Jeff. Know I have two replies: One saying 
>primary keys
>can be primitive types and one that says they can't.
>I am really looking forward to hearing your arguments, gentlemen ;-)
>
>BTW, Jeff: Your answer to question number 1 - do you have that from the
>specification, or...
>
>Randahl
>
>-----Original Message-----
>From: [EMAIL PROTECTED]
>[mailto:[EMAIL PROTECTED]]On Behalf Of Jeff 
>Schnitzer
>Sent: 1. marts 2001 02:52
>To: Orion-Interest
>Subject: RE: Database schema type mappings
>
>
>>From: Randahl Fink Isaksen [mailto:[EMAIL PROTECTED]]
>>
>>1. Why is Integers automatically converted to int by Orion -
>>and is this a
>>standard EJB convention?
>
>Yes.  All the class representations of the primitive types should work
>that way.
>
>>2. Would it be legal to have a primary key of the primitive type "int"
>>instead of Integer?
>
>No.  Primary keys must be Objects.  This makes sense because
>EntityContext.getPrimaryKey() returns an Object.
>
>Jeff
>
>
>

Reply via email to