0 Replies Latest reply on Aug 15, 2002 7:25 AM by fredericagneray

    many-to-one unidirectional relationship with xdoclet is bugg

    fredericagneray

      How can I get a many-to-one unidirectional relationship using XDoclet 1.1.2. Say I want to implement a unidirectional relationship from CruiseEJB to ShipEJB (the Monson-Haefel example) a Cruise got only one Ship, but a Ship had many Cruises. And you're only interrested in a link between Cruise->Ship and don't want Ship->Cruise. So this is a typical many-to-one unidirectional. The XDoclet bits within Cruise will be somthing like:

      /**
      * @ejb:relation name="Cruise-Ship"
      * role-name="Cruises-has-one-Ship"
      * target-ejb="Ship"
      * target-role-name="Ship-has-many-Cruises"
      * target-multiple="no"
      */


      but then there's no way I can tell cruise is many in this relationship. And my descriptor is:

      <ejb-relation >
      <ejb-relation-name>Cruise-Ship</ejb-relation-name>
      <!-- unidirectional -->
      <ejb-relationship-role >
      <ejb-relationship-role-name>Cruises-has-one-Ship</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Cruise</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>ship</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role >
      <ejb-relationship-role-name>Ship-has-many-Cruises</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Ship</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>


      when I would like it to be:

      <ejb-relation >
      <ejb-relation-name>Cruise-Ship</ejb-relation-name>
      <!-- unidirectional -->
      <ejb-relationship-role >
      <ejb-relationship-role-name>Cruises-has-one-Ship</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>Cruise</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>ship</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>
      <ejb-relationship-role >
      <ejb-relationship-role-name>Ship-has-many-Cruises</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>Ship</ejb-name>
      </relationship-role-source>
      </ejb-relationship-role>
      </ejb-relation>

      Looks like to be able to produce the second descriptor and produce a many-to-one relationship we will need to modify XDoclet and produce a custom tag. I'm surprised as I thought that was common code generation and expect many people would have use this feature... So XDoclet not being able to produce this feature come as a shock, and appear like a major bug.

      And when I look at the XDoclet code the way it find out if it is a multiple relationship is by cheking if the return object is a collection. However because it is not bidirectional in this case it should look for a key-word (like multiple inside the @ejb:relation) that will tell it is a many-to-one. So it look a lot like a bug. Please correct me if I'm wrong...