Some problems controlling the mapping of CMR fields to table
exbrayat Nov 4, 2004 6:50 AMHie all,
I use a unidirectional relationship between 2 entity ejbs, I have a 1-M relationship, and would like to control the name of the relation attribute on the M side.
I used the xdoclet tag @jboss.target-relation (which seems to provide this), but this does not work...
On the 1 side the doclet and code is as follows :
/** * Getter for CMR Relationship * * @ejb.interface-method view-type="local" * @ejb.relation name = "Prod-Prod2" * role-name = "Test" * target-ejb = "Products2" * target-role-name = "ProductsToProducts2" * target-multiple = "no" * @jboss.relation * related-pk-field = "pid" * fk-column = "pid" */ public abstract Collection getProducts2(); /** * Setter for CMR Relationship * * @ejb.interface-method view-type="local" */ public abstract void setProducts2(java.util.Collection value);
where pid is the pk of this entity.
The ejb-jar.xml contains the following :
<relationships > <ejb-relation > <ejb-relation-name>Prod-Prod2</ejb-relation-name> <ejb-relationship-role > <ejb-relationship-role-name>Test</ejb-relationship-role-name> <multiplicity>One</multiplicity> <relationship-role-source > <ejb-name>Products</ejb-name> </relationship-role-source> <cmr-field > <cmr-field-name>products2</cmr-field-name> <cmr-field-type>java.util.Collection</cmr-field-type> </cmr-field> </ejb-relationship-role> <ejb-relationship-role > <ejb-relationship-role-name>ProductsToProducts2</ejb-relationship-role-name> <multiplicity>Many</multiplicity> <relationship-role-source > <ejb-name>Products2</ejb-name> </relationship-role-source> </ejb-relationship-role> </ejb-relation>
and the jbosscmp-jdbc.xml contains :
<ejb-relation> <ejb-relation-name>Prod-Prod2</ejb-relation-name> <ejb-relationship-role> <ejb-relationship-role-name>Test</ejb-relationship-role-name> <key-fields/> </ejb-relationship-role> <ejb-relationship-role> <ejb-relationship-role-name>ProductsToProducts2</ejb-relationship-role-name> <key-fields> <key-field> <field-name>pid</field-name> <column-name>pid</column-name> </key-field> </key-fields> </ejb-relationship-role> </ejb-relation>
Well, when the app gets deployed, the products2 table is created with a field named "products_products2" (while I was expecting "pid").
I use jboss-4.0.0
Where is the problem ?
Thanks for help