3 Replies Latest reply on Mar 30, 2003 6:54 PM by goldrimtang

    Problem with XDoclet generated deployment discriptors

    sczadzeck

      I'm using XDoclet to create my deployment files. I keep getting the following error when deploying to JBoss:

      Depends On Me: org.jboss.deployment.DeploymentException: Role: item-belongs-to-instruction with multiplicity many using foreign-key mapping is not allowed to have key-fields, ObjectName: jboss.j2ee:jndiName=nemesis/BuildItem,service=EJB state: FAILED

      Does anyone have an idea what the cause of this is?

      Thanks in advance.

      Scott

        • 1. Re: Problem with XDoclet generated deployment discriptors
          jcordes

          Hi Scott !

          The section in jbosscmp-jdbc.xml should look like this:

          <ejb-relation> <ejb-relation-name>Instruction-Items</ejb-relation-name>
          <foreign-key-mapping/>
          <ejb-relationship-role> <ejb-relationship-role-name>item-belongs-to-instruction</ejb-relationship-role-name>
          <key-fields/>
          </ejb-relationship-role>
          <ejb-relationship-role>
          <ejb-relationship-role-name>instruction-has-items</ejb-relationship-role-name>
          <key-fields>
          <key-field>
          <field-name>id</field-name>
          <column-name>instruction_id</column-name>
          </key-field>
          </key-fields>
          </ejb-relationship-role>
          </ejb-relation>

          What seems to be of matter here is that the key-field entries in your case may be swapped.
          The deployment entries above can be generated by using these XDoclet-Tags (assuming the relation is bidirectional for ease ;-) ):

          Instruction

          /**
          * @ejb.interface-method
          * @ejb.relation name="Instruction-Item"
          * role-name="instruction-has-items"
          */
          public abstract Collection getItems();

          Item

          /**
          * @ejb.interface-method
          * @ejb.relation name="Instruction-Item"
          * role-name="item-belongs-to-instruction"
          * @jboss.relation related-pk-field="id" fk-column="instruction_id"
          */
          public abstract InstructionEJBLocal getInstruction();

          Hope it helps,

          Jochen.

          • 2. Re: Problem with XDoclet generated deployment discriptors
            sczadzeck

            That solved my problem. You are my saviour! :-)

            Scott

            • 3. Re: Problem with XDoclet generated deployment discriptors
              goldrimtang

              I had the same problem, but I couldn't move the @jboss.relation tag to the other entity bean because the relationship is unidirectional.
              The way to solve this was using @jbos.target-relation. I found this quite obscure and almost undocumented, but works fine.