8 Replies Latest reply on Oct 20, 2004 6:25 AM by pablojavierpy

    incomplete jbosscmp-jdbc.xml generated using xdoclet+jboss

    sudhir_suman

      I created a 1:m relation between two beans as follows:

      /**
      *@ejb.relation
      * name="FolderMayContainDevices"
      * role-name="FolderToDevices"
      * target-ejb="Device"
      * target-multiple="yes"
      * target-role-name="DeviceToFolder"
      *
      *@jboss.relation
      * related-pk-field="id”
      * fk-column="folderId”
      *
      *@ejb.interface-method
      *
      */
      public abstract Collection getDevices(Integer folderId);

      I get deployment error like this:

      org.jboss.deployment.DeploymentException: Atleast one role of a foreign-key mapped relationship must have key fields (or <primkey-field> is missing from ejb-jar.xml): ejb-relation-name=FolderMayContainDevices

      And I notice in jbosscmp-jdbc.xml that key-fields are empty. Are we missing any attribute in ant task?



      <ejb-relation>
      <ejb-relation-name>FolderMayContainDevices</ejb-relation-name>
      <relation-table-mapping>
      </relation-table-mapping>

      <ejb-relationship-role>
      <ejb-relationship-role-name>FolderToDevices</ejb-relationship-role-name>
      <key-fields/>
      </ejb-relationship-role>
      <ejb-relationship-role>
      <ejb-relationship-role-name>DeviceToFolder</ejb-relationship-role-name>
      <key-fields>
      <key-field>
      <field-name></field-name>
      <column-name></column-name>
      </key-field>
      </key-fields>
      </ejb-relationship-role>

      I guess the field-name and column-name need data here. but what is making it not appear with generation

      ant 1.6.2
      jboss 4.0
      xdoclet 1.2.1

      Your help is appreciated.



        • 1. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
          pablojavierpy

          This example works for me with same configuration:

          /**
          * @ejb.relation
          * name = "Party-PartyTaxInformation"
          * role-name="Party-has-PartyTaxInformations"
          * target-ejb="PartyTaxInformationEJB"
          * target-role-name = "PartyTaxInformation-of-Party"
          * target-cascade-delete = "yes"
          * target-multiple = "no"
          * @jboss.target-relation
          * related-pk-field = "partyId"
          * fk-column = "partyId"
          * fk-constraint = "true"
          *
          * @ejb.interface-method view-type = "local"
          */
          public abstract Collection getPartyTaxInformations();
          /**
          *
          * @ejb.interface-method view-type = "local"
          */
          public abstract void setPartyTaxInformations(Collection partyTaxInformations);

          Hope this helps.

          • 2. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
            sudhir_suman

            Hi,

            in your example, target-multiple="no" and u are requesting for collection of TaxInformations? are u implementing 1:1 or 1:m relation here?

            can u send/post me your build scrpt where u generate this?

            thanks
            Sudhir

            here is mine.






            <!-- Comment the next two lines, if you do not want to e
            xpose the Beans via the Remote Interface -->









            • 3. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
              sudhir_suman

              One more question,

              is "partyId" defined as key in "PartyTaxInformationEJB" ?

              thanks

              • 4. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
                pablojavierpy

                Yes, I am implementing 1:m relationships. Do you think the tag is wrong?

                What does ejb-jar.xml says about your <primkey-field> tag? Is it set correctly? Error you are getting seems to be caused by a wrong primary key setting. Am I right?

                No, partyTaxInformationId is defined as key in PartyTaxInformationEJB:

                Check the ejb-jar.xml


                <![CDATA[Party Tax Information]]>
                <display-name>PartyTaxInformation EJB</display-name>

                <ejb-name>PartyTaxInformationEJB</ejb-name>

                <local-home>py.com.roshka.wops4.party.taxInformation.interfaces.PartyTaxInformationEJBLocalHome</local-home>
                py.com.roshka.wops4.party.taxInformation.interfaces.PartyTaxInformationEJBLocal

                <ejb-class>py.com.roshka.wops4.party.taxInformation.ejb.PartyTaxInformationEJB</ejb-class>
                <persistence-type>Container</persistence-type>
                <prim-key-class>java.lang.Integer</prim-key-class>
                False
                <cmp-version>2.x</cmp-version>
                <abstract-schema-name>PartyTaxInformationEJB</abstract-schema-name>
                <cmp-field >
                <![CDATA[]]>
                <field-name>partyTaxInformationId</field-name>
                </cmp-field>
                <cmp-field >
                <![CDATA[]]>
                <field-name>taxAuthority</field-name>
                </cmp-field>
                <cmp-field >
                <![CDATA[]]>
                <field-name>taxPercent</field-name>
                </cmp-field>
                <cmp-field >
                <![CDATA[]]>
                <field-name>taxRegistrationNumber</field-name>
                </cmp-field>
                <cmp-field >
                <![CDATA[]]>
                <field-name>typeOfTaxRegistration</field-name>
                </cmp-field>
                <primkey-field>partyTaxInformationId</primkey-field>


                <query-method>
                <method-name>findAll</method-name>
                <method-params>
                </method-params>
                </query-method>
                <ejb-ql><![CDATA[SELECT OBJECT(o) FROM PartyTaxInformationEJB o]]></ejb-ql>

                <!-- Write a file named ejb-finders-PartyTaxInformationEJB.xml if you want to define extra finders. -->


                -----------------------

                Hope this helps.

                • 5. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
                  sudhir_suman

                  thanks Pablo Javier Santa Cruz Cosp,

                  i used ur example and it worked. even with target-mutliple = "yes"

                  • 6. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
                    pablojavierpy

                    No prob. Have had your same problem!

                    Good luck.

                    • 7. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
                      sudhir_suman

                      hi Pablo,

                      have you used a bi-directional relationship in the same setup. i get deployment errors saying the key fields are not defined and i checked jbosscmp-jdbc.xml , they are not generated.

                      uni-directional works fine.

                      if u have an example, please reply

                      thanks

                      • 8. Re: incomplete jbosscmp-jdbc.xml generated using xdoclet+jbo
                        pablojavierpy

                        No. I haven't use bidirectional. If you are using bi-directionar, remember to remove "taget" doclet tags in both sides, and the relation-name must be equal in both sides.

                        If I have an example working, I will let you know.

                        Just wondering, what database engine are you using for persistence?