0 Replies Latest reply on May 11, 2004 3:38 PM by didi

    CMR with xdoclet for jboss

    didi

      Hi everybody!

      I thought I would never use hypersonic sql as db but now I have to :-/

      A short description of my situation:
      I have a QuestionEntityBean and a AnswerEntityBean. It is obvious the ONE Question can have MANY Answers. So I defined

      /**
      * @ejb:persistent-field
      * @ejb:pk-field
      *
      * @jboss:column-name name="id"
      */
      public abstract int getId();

      public abstract void setId(int id);

      /**
      * @ejb:persistent-field
      *
      * @ejb:relation name="idAnswerQuestion"
      * role-name="each-question-has-a-lot-of-answers"
      * target-multiple="no"
      *
      * @jboss:target-relation related-pk-field="id"
      * fk-column="answers"
      *
      * @jboss:column-name name="answers"
      */
      public abstract Collection getAnswers();

      public abstract void setAnswers(Collection answers);



      with xdoclet in the QuestionEntityBean. My AnswerEntityBean looks like this:

      /**
      * @ejb:persistent-field
      * @ejb:pk-field
      *
      * @ejb:relation name="idAnswerQuestion"
      * role-name="a-lot-of-answers-belong-to-one-question"
      * target-multiple="yes"
      *
      *
      * @jboss:column-name name="id"
      */
      public abstract int getId();

      public abstract void setId(int id);

      (ok at the moment they are still stupid but it is just to get the CMR running).
      Everything compiles but JBoss comlains

      22:19:44,676 WARN [ServiceController] Problem starting service jboss.j2ee:jndiName=ejb/cobana/AnswerEntity,service=EJB
      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=idAnswerQuestion

      I see the point that the mapping is missing in my ejb-jar.xml

      <!-- Relationships -->

      <ejb-relation >
      <ejb-relation-name>idAnswerQuestion</ejb-relation-name>

      <ejb-relationship-role >
      <ejb-relationship-role-name>a-lot-of-answers-belong-to-one-question</ejb-relationship-role-name>
      Many
      <relationship-role-source >
      <ejb-name>AnswerEntity</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>id</cmr-field-name>
      </cmr-field>
      </ejb-relationship-role>

      <ejb-relationship-role >
      <ejb-relationship-role-name>each-question-has-a-lot-of-answers</ejb-relationship-role-name>
      One
      <relationship-role-source >
      <ejb-name>QuestionEntity</ejb-name>
      </relationship-role-source>
      <cmr-field >
      <cmr-field-name>answers</cmr-field-name>
      <cmr-field-type>java.util.Collection</cmr-field-type>
      </cmr-field>
      </ejb-relationship-role>

      </ejb-relation>


      but I have no clue how to configure it with xdoclet (or is it another bug?).

      Does someone had the same problem? Can someone help me?

      THANKS IN ADVANCE