Dan,

This is not really an EJB question, but more of a Java question.
You are right in pointing out that an instance of "int" is not
an instance of "Object" in Java.  (If it were, we would be pretty
much be programming in Smalltalk, which would not be a bad thing
in and of itself.)

So, how do APIs in Java which are untyped handle this problem.
For example, the reflection APIs in Java are untyped.  So, how
do I call a method using reflection which takes an "int" parameter.
The answer, of course, is to use wrapper types.  So instead of
an "int", I have to pass an "Integer".  So it goes with EJB, at
least in our product.  The PK type will be "int", but if you
call getPrimaryKey (which is an untyped method) you get back
an "Integer" containing the PK's value.

Again, the benefit with this approach is that it is syntactically
invalid to set the PK to null.  An "int" can never have a
null value.  Which again, is very much in alignment with the
concept of a primary key.

So again, "int" ought to be a valid PK type.  Why would it not
be?

-jkw

Dan OConnor wrote:
>
> On 21 Apr 00, at 13:47, Jonathan K. Weedon wrote:
>
> >
> > <vendor>
> > Our product supports either "int" or "Integer" as a PK type,
> > as well as all other primitive or primitive wrapper types.
> > </vendor>
> >
> > It is not clear to me if this is compliant or not with the
> > EJB 1.1 specification.  Should only primitive wrappers be
> > allowed.  And if so, is this sensible, given again that
> > "int", in Java, means essentially "non-null Integer", which
> > is a pretty reasonable type for a primary key field.
> >
>
> Hi Jonathan,
>
> I believe that using primitive types such as int for a primary key is
> non-conformant.  What I'm really curious about, though, is how you
> manage to support it.
>
> For instance, how do you support the remove( Object primaryKey )
> function in EJBHome?  Or what do you return from finders with
> more than one result, since neither java.util.Enumeration nor
> java.util.Collection supports primitive types?  Or what do you return
> from EJBObject's getPrimaryKey?
>
> Do you just wrap the primitive type all over the place?  Or do you
> have some other strategy?
>
> Thanks,
>
> -Dan
>
> ===========================================================================
> 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