-
1. Re: CMR field as a part of the primary key
pdelgado0 Jun 17, 2003 12:16 PM (in response to pdelgado0)Hello again,
Some days after posting the previous message I found the solution (I upgraded from Jboss 3.0.7 to 3.2.0 but I'm not sure if it was part of the reason)
If you want to have a CMR field as part of the primary key of an EB, you have to create the same field also as a CMP field and join them at the column-name attribute, I mean, if you have this relationship
Token (1) --------------- (*) Availability
in the availability EB .... (using xdoclet)
/**
* @ejb.pk-field
* @ejb.interface-method
* @ejb.persistent-field
* @ejb.persistence
* column-name="id_token_fk"
* jdbc-type="BIGINT"
* sql-type="bigint"
*/
abstract public Long getIdtoken ();
and also the CMR field ...
/**
* CMR abstract accesors TOKEN-AVAILABILITY
*
* @ejb.interface-method
* view-type="local"
* @ejb.relation
* name="token-availability"
* role-name="availability-belongs-to-token"
* target-multiple="yes"
*
* @jboss.relation
* related-pk-field="idtoken"
* fk-column="id_token_fk"
* fk-constraint="true"
*/
public abstract TokenLocal getToken();
where if you notice, the "column-name" and "fk-column" have the same value (id_token_fk).
Doing this, you keep the relationship and the all the constraints you may need and it does not create two columns. It only creates one and is part of the relationship and part of the PK of the EB.
I hope this information may help somebody.
Regards.
Pablo Delgado