Dear sankar, I think you are write. Comtainer manages the bean persistence for both CMP and CMR fields you just have to declare the Abstract schema.. so the conversion is done automatically. Cotainer figures it out by the abstract getters and setters in the bean class. vikas prasad SCJP1.4 SCWCD 1.4 SCBCD 1.3
The Bean Provider uses the primkey-field element of the deployment descriptor to specify the container-managed field of the entity bean class that contains the primary key. The field�s type must be the primary key type.
This means, if a cmp-field is also a primkey-field then it cannot be primitive type (because a primary key has to be an object). Is it correct ?
Googled and got the answer: The cmp-field used as simple primary key can be primitive as long as it is possible for the container to convert it to its specified Wrapper type.
[ UD: removed link to copyrighted material ]
[ December 20, 2005: Message edited by: Sankar Subbiramaniam ] [ August 03, 2007: Message edited by: Ulf Dittmer ]
Any CMP field can be a PK so long as it is serializable. If you select a primitive as the PK and rely on the container doing a conversion to the wrapper, then this does not comply with the EJB spec (which is what matters to you).
I did not understand your answer. Lets take an example: Entity baean has two fields: int id String name
Now in the DD, i specify as follows: <prim-key-class>java.lang.Integer</prim-key-class> <cmp-field> <field-name>id</field-name> </cmp-field> <cmp-field> <field-name>name</field-name> </cmp-field> <primkey-field>id</primkey-field>
Is this correct ? or should i change "id" type to java.lang.Integer ?