1 Reply Latest reply on May 14, 2004 3:37 PM by sesques

    relationship doubt

    nacho2004

      Hi everybody!
      I've 2 tables :
      CatDocuments and Documents
      CatDocuments has docid and catid fields
      Documents has docid and docname fields
      The relation between both are with the docid field
      I want to get all the docs from documents where catid =x
      for example
      [select docname from catdocuments a inner join documents b on a.docid=b.docid where catid = xxx]
      well,
      I' been created a code like this in Documents bean
      /**
      * @ejb.interface-method
      * view-type="both"
      *
      * @ejb.persistence
      * column-name = "docid"
      *
      * @ejb.relation
      * name="EDocuments-ECatDocuments"
      * target-ejb="ECatDocuments"
      * target-multiple="no"
      * role-name="EDocuments-has-ECatDocuments"
      *
      * @jboss.relation
      * related-pk-field="docid"
      * fk-column="docid"
      *
      */
      public abstract Collection getCatDocuments();
      /**
      * @ejb.interface-method
      * view-type="both"
      */
      public abstract void setCatDocuments(int docid);



      and in the CatDocuments bean I put the next code

      /**
      * @ejb.interface-method
      * view-type="both"
      *
      * @ejb.persistence
      * column-name = "docid"
      *
      * @ejb.relation
      * name="EDocuments-ECatDocuments"
      * target-ejb="EDocuments"
      * target-multiple="yes"
      * role-name="ECatDocuments-has-EDocuments"
      *
      * @jboss.relation
      * related-pk-field="docid"
      * fk-column="docid"
      *
      */
      public abstract Collection getDocuments();
      /**
      * @ejb.interface-method
      * view-type="both"
      */
      public abstract void setDocuments(int docid);


      so, the question is ....
      1) if the code above is right and
      2) why I want to deploy the code that error appear

      org.jboss.deployment.DeploymentException: No ejb-relationship-role-name element found

        • 1. Re: relationship doubt
          sesques

          I suggest you to look carefully at the XDoclet documentation.

          If you define collections in both sides, your relation is a many-many one and should use a third table.

          You cannot specify the
          @jboss.relation
          * related-pk-field="docid"
          * fk-column="docid"
          on both sides, just on the many side.

          I that the Xdoclet parser goes crazy with your tags.
          Use search on this forum. On many topics, you can find code snippet for relationships tags.

          Pascal