This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes Help me out for EJB2.0 CMR fields mapping in XDOCLET....... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Help me out for EJB2.0 CMR fields mapping in XDOCLET......." Watch "Help me out for EJB2.0 CMR fields mapping in XDOCLET......." New topic
Author

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

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
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


********Deserve Before You Desire********
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Help me out for EJB2.0 CMR fields mapping in XDOCLET.......