Hello,
I think you must have all of four values inside your primary key class
EXACTLY matching with four values inside your ejb class.
For example:
class MyEJB {
public String field1;
public String field2;
public int field3;
public int field4;
...
public MyEJBPrimaryKey ejbCreate(...) {
... // field1=..., field2=... etc.
return null;
}
}
class MyEJBPrimaryKey {
public String field1;
public String field2;
public int field3;
public int field4;
public MyEJBPrimaryKey() {} // <-- This constructor is
mandatory
}
When deploying, you have to specify there is no primary key (omitting
<primkey-field> in ejb-jar.xml file) -in ypur ejb- and that the primary key
type is MyEJBPrimaryKey(with <prim-key-class> in ejb-jar.xml).
I hope this can help you. Regards.
Luis F. Canals Samaniego
CEDETEL
Parque Tecnol�gico de Boecillo
Edificio Centro, Parcela 109
E-47151 Boecillo (Valladolid)
-----Mensaje original-----
De: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]En nombre de Sivakumar_Subramanian
Enviado el: jueves 29 de junio de 2000 12:23
Para: [EMAIL PROTECTED]
Asunto: primary key class with different compostie primary keys
Hi all,
How do u define a primary key class for 4 composite primary keys
with 2 primary keys as string and another 2 as double value. I am trying to
write a primary key class by concatenating the strings(double values are
also casted to string but there is the problem. i am not able to do it.
pls help me out.
am i right or i am missing something here.
-----------------------------------------------
Sivakumar Subramanian
Satyam Computer Services Ltd,
M.G. Road, Bangalore, India
EMail : [EMAIL PROTECTED]
Ph: 91-80-5597171 Extn: 3657
-----------------------------------------------
> ----------
> From: Ram Komarraju[SMTP:[EMAIL PROTECTED]]
> Reply To: A mailing list for Enterprise JavaBeans development
> Sent: Thursday, June 29, 2000 12:06 AM
> To: [EMAIL PROTECTED]
> Subject: Re: java.util.Date
>
> I attached below a post made yesterday by Scott Ellis in this forum. I
> think
> that should answer your question :)
>
> <quote>
>
> I've been having some problems with the primary key class lately, and I
> have
> looked for a book that really describes the process. I found O'Reilly's
> Enterprise JavaBeans devotes a lot of time to the subject if you are
> intersted in picking it up. I got it because it was recommended by the
> website www.ejbnow.com . To get the primary key class right, you are
> going
> to need a good reference.
>
> Basically you need to make sure that the primary key class has public
> member
> variables that match exactly in type and name of the same fields in your
> implementation bean. The pk class must be serializable and implement the
> equals and hashCode methods, and must have a default empty constructor.
> I'm
> not sure if it is required, but you also provide a constructor that
> contains
> the key values. The hashCode method I don't really know a lot about, but
> at
> ejbnow.com, there is a tips page that describes how to code it.
>
> In your ejb-jar.xml, make sure to not specify
> <primkey-field>...</primkey-field>. When you specify a custom
> prim-key-class you don't need this entry, and it will mess you up. Trust
> me. So if your primary key class is called CustomerPK, then your entry
> for
> the class in ejb-jar.xml is ( assuming no package name )
>
> <prim-key-class>CustomerPK</prim-key-class>
>
> Then you need to specify your primary key class in the home interface in
> findByPrimaryKey, and it must be the return type of all of your ejbCreates
> in the bean implementation.
>
> </quote>
>
> Scott
>
> ==========================================================================
> =
> 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".