Hi,

   I had sucess in make xdoclet create entitys using CMP 2.0.
   But I am with a problem with relationships.
   I already send this question to 2 list members before post to the list, 
it must be something very stupid but I am not getting this right.
   This happens using XDoclet 1.1.2.
   I have 2 tables Orders and Items and a relationship on them. One order 
can have 0..n items and all items had just one order. I can navigate from 
Order to Items (Collection c = Order.getItems()) but not on the other side 
(no Order o = Item.getOrder()).
   So this is what I have on my OrderEjb.java file :

/**
* @ejb:relation name="Order-Item"
*   role-name="Order-has-items"
*   target-role-name="items-is-in-order"
*   target-ejb="Item"
*/

    public abstract Collection getItems();

    public abstract void setItems(Collection Items);

   This will create on ejb-jar.xml this :

    <relationships>
       <ejb-relation>
          <ejb-relation-name>Order-Item</ejb-relation-name>
          <ejb-relationship-role>
             <ejb-relationship-role-name>Order-has-items</ejb-relationship-role-name>
             <multiplicity>Many</multiplicity>
             <relationship-role-source>
                <ejb-name>Orders</ejb-name>
             </relationship-role-source>
             <cmr-field>
                <cmr-field-name>items</cmr-field-name>
                <cmr-field-type>java.util.Collection</cmr-field-type>
             </cmr-field>
          </ejb-relationship-role>
          <ejb-relationship-role>
             <ejb-relationship-role-name>items-is-in-order</ejb-relationship-role-name>
             <multiplicity>Many</multiplicity>
             <relationship-role-source>
                <ejb-name>Item</ejb-name>
             </relationship-role-source>
          </ejb-relationship-role>
       </ejb-relation>
    </relationships>

   The problem is the <multiplicity> is set to many on both sides of the 
relationship. I think it bust be "One" on the "Order-has-items" side and 
"Many" on the "items-is-in-order" side.
   Using the target multiple property I can change this to the 
"items-is-in-order" side. But how I can change it to the other side ?

   If you want try it you can download this sample (it is <3 Kb file) with 
the source code and the build.xml file I am using :

http://www.danilo.floripa.com.br/Cmp2Relation.zip


----
Danilo Luiz Rheinheimer
Florianopolis/SC Brasil
Sony Cli� 615C
mailto:[EMAIL PROTECTED]
----


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
Xdoclet-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-user

Reply via email to