This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me out for EJB2.0 CMR fields mapping in XDOCLET.......

 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using CMR for EJB2.0 with JBOSS 4.0 as application server. Now I have 2 Beans CartMaster & CartDetail with one to Many relationship.
Now in Bean Implementation file i write following code in XDOCLET form.

CartMasterBean.java
========
/**
* @ejb.interface-method
* @ejb.relation name="cartmaster-to-cartdetail"
*
* role-name="CartMaster-has-many-CartDetail"
* target-ejb="ejb/CartMaster"
* target-role-name="CartDetail-has-one-CartMaster"
*
* @jboss.relation related-pk-field = "cartid"
fk-column = "cartdetailid"
* fk-constraint = "true"
* @return
*/

public abstract Collection getDetail();

/**
* @ejb.interface-method
*/
public abstract void setDetail(Collection c);

=======

CartDetailBean.java
=================
/**
* @ejb.interface-method
*
* @ejb.relation name="cartmaster-to-cartdetail"
* role-name="CartDetail-has-one-CartMaster"
* target-ejb="ejb/CartMaster"
* target-role-name="CartMaster-has-many-CartDetail"
*target-multiple = "true"
* @jboss.relation fk-column="cartid"
* related-pk-field="cartdetailid"
*
* @return
*/

public abstract CartMaster getParent();
/**
* @ejb.interface-method
*/
public abstract void setParent(CartMaster el);


=================


But when I run XDOCLET on it I m getting following code in My ejb-jar.xml inside <relationships > tag:-
=========
<relationships >
<ejb-relation >
<ejb-relation-name>cartmaster-to-cartdetail</ejb-relation-name>
<ejb-relationship-role >
<ejb-relationship-role-name>CartDetail-has-one-CartMaster</ejb-relationship-role-name>
<multiplicity>Many</multiplicity>
<relationship-role-source >
<ejb-name>CartDetail</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>parent</cmr-field-name>
</cmr-field>
</ejb-relationship-role>

<ejb-relationship-role >
<ejb-relationship-role-name>CartMaster-has-many-CartDetail</ejb-relationship-role-name>
<multiplicity>One</multiplicity>
<relationship-role-source >
<ejb-name>CartMaster</ejb-name>
</relationship-role-source>
<cmr-field >
<cmr-field-name>detail</cmr-field-name>
<cmr-field-type>java.util.Collection</cmr-field-type>
</cmr-field>
</ejb-relationship-role>
</ejb-relation>
</relationships>
=========

Here Problem is that I have specified the "cartid" & "cartdetailid" as Pk-field & foreign key fields in XDOCLET. But after running XDOCLET I am getting the CMR field names as "parent" & "detail" respectively. Why it is Happening? Also when I trying to deploy jar file on server It gives me error like:-
==================
12:20:57,437 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/CartDetail,service=EJB
org.jboss.deployment.DeploymentException: Role: CartDetail-has-one-CartMaster with multiplicity many using foreign-key mapping is not allowed to have key-fields
..............
===================

How to solve this?
Pleas ehelp me.

Thanx in Advance.......

Prash
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic