cancel
Showing results for 
Search instead for 
Did you mean: 

Using an object als Primary Key

Former Member
0 Kudos

Hello,

is it possible to define in the persistent.xml file an object as a primary key?. I mean something like

<field-map key-type="PrimaryKey">

<field-name>ProductPK</field-name>

<column>

<column-name>PRODUCTID</column-name>

</column>

</field-map>

ProductPK implements the toString(), hashCode() and equals(Object obj) methods.

Thanks for your answer,

SL

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

i think there is something goes wrong in your Implementation.

1. If you only have one field as primary key you don't need a PK class. You only have to define this fiel with the key-type PrimaryKey in persistent.xml.

2. The ejbCreate Method must return the type of the primary key. So if your primary key is productID let it return a String.

Try this out and tell me if it works.

Regards André

Message was edited by: André Rauscher

Sorry the ejbCreateMethode can have parameter.

Former Member
0 Kudos

In persistent.xml you have to define all fields which represents the primaryKey as key-type="PrimaryKey". In the ejb-jar.xml you should define your PrimaryKey Class like:

Regards André

Former Member
0 Kudos

Hello André,

i defined in the persistent.xml:

...

: the pk-type is not equal to the cmp-field type.;

any idea?

Regards,

SL