Hi H�l�ne,
you are absolutely right and I don't have any problem with it. I was just
doing evaluation of IBM Webshere and it handles it exactly according to spec
(and exactly how you have described - it doesn't allow any nonpublic
variables and any constants) and it is even more restrictive (with couple of
bugs), because it requires to override toString(), hashCode() and equals().
So in my opinion this means that the EJB spec is too restrictive when it
doesn't allow constants (and then there is nothing I can do). My example is
this.
public class MyPrimaryKey
{
// This is the constant identifying undefined key
public static final int UNDEFINED_KEY = -1;
// This is the actual key
public int m_iID;
}
To get around the limitation of the spec I had to move UNDEFINED_KEY to a
separate interface and MyPrimaryKey class cannot implement this interface.
It is no big deal, just little annoying.
Anyway, thanks for your help,
Miro Halas
-----Original Message-----
From: Helene JOANIN [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 10, 1999 3:25 AM
To: Halas, Miroslav
Cc: [EMAIL PROTECTED]
Subject: Re: Primary Key class problem
Hi,
My understanding about the primary key class is that it is a
very 'simple' class, just needed to define which fields of
the entity identify an entity.
Is this sight too simple ?
Could you give me your example ?
Regards.
H�l�ne.
Halas, Miroslav wrote:
>
> I agree what you said, because it is following the EJB specification, but
> from the usability standpoint, it is always desirable to define constants
> you use throughout the code at one place. Because Java doesn't allow
> #define, the only way is to declare them as a static final variables. To
get
> around the specification it is possible to move the constants into
separate
> interface implemented by the primary key class, but then, when you fix the
> other problem I have found (derived primary key class) it may reappear
> again. Do you have some other suggestion, how to deal with constants in
> primary key classes?
>
> Regards,
>
> Miro
>
> -----Original Message-----
> From: Helene JOANIN [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 09, 1999 3:58 AM
> To: Halas, Miroslav
> Cc: '[EMAIL PROTECTED]'; Helene JOANIN
> Subject: Re: Primary Key class problem
>
> Halas, Miroslav wrote:
> >
> > Hi,
> >
> > I have a primary key class for EntityBean, which contains several public
> and
> > protected static member variables (numbers and texts used as constants)
> all
> > marked as transient. When I use GenIC, I get an error:
> >
> > GenIC ERROR: The field [name of the public/protected static final member
> > variable] of the Primary Key class is not a container-managed field of
the
> > Entity Bean
> >
> > This code works with Weblogic 4.5.1 so I am wondering if it is a bug in
> > Jonas?
> >
>
> Hi,
>
> We can find in the specification of EJB version 1.0 chapter 9.10.7,
> and in the specification of EJB version 1.1 chapter 9.4.7.2,
> the following sentences about the primary key class of an entity
> bean with container-managed persistence :
>
> All fields in the primary key class must be declared as public.
>
> The names of the fields in the primary key class must be a subset
> of the names of the container-managed fields. (This allows the
> container to extract the primary key fields from an instance's
> container-managed fields, and vice versa.)
>
> That's why we think it's not a bug in JOnAS.
> Are you agree ?
>
--
-=- H�l�ne JOANIN -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
mailto:[EMAIL PROTECTED] http://www-frec.bull.com
Phone: 33.4.76.29.73.53 Fax: 33.4.76.29.76.00
Download our EJB Server JOnAS at http://www.bullsoft.com/ejb
_______________________________________________________________