2 Replies Latest reply on Apr 18, 2002 9:57 AM by Wilfried

    xdoclet many to many problem

    Clement Newbie

      i got some problem using xdoclet with many to many relationship,
      --------
      PartsBean
      /**
      * @ejb:relation name="PartsProduct"
      * role-name="role2" multiple="yes"
      * @jboss:relation-table
      * table-name="Parts_Product"
      * @jboss:relation
      * related-pk-field="productId" fk-column="Product_ID"
      */
      public abstract Collection getProducts();
      ---------
      ProductBean
      /**
      * @ejb:relation name="PartsProduct"
      * role-name="role2" multiple="yes"
      * @jboss:relation-table
      * table-name="Parts_Product"
      * @jboss:relation
      * related-pk-field="productId" fk-column="Product_ID"
      */
      public abstract Collection getProducts();
      --------------

      After deploy it, the error occer said:
      CMP field for key not found: field name= productId

      please help.
      PS: got any good example for xdoclet relationship, 1 to many , 1to1 and many to many ...
      thx

        • 1. Re: xdoclet many to many problem
          Clement Newbie

          sorry wrong PartsBean
          /**
          * @ejb:relation name="PartsProduct"
          * role-name="role1" multiple="yes"
          * @jboss:relation-table
          * table-name="Parts_Product"
          * @jboss:relation
          * related-pk-field="partsId" fk-column="Parts_ID"
          */
          public abstract Collection getProduct();

          • 2. Re: xdoclet many to many problem
            Wilfried Newbie

            Here's one many-2-many relationship that is working for me:

            OrderBean
            =======================================================

            /**
            * @ejb:bean name="Order" type="CMP" primkey-field="id" view-type="local"
            * @ejb: pk class="java.lang.Long"
            * @ejb:transaction type="Supports"
            * @ejb:home generate="local"
            * @ejb:interface generate="local"
            * @ejb: permission unchecked=""
            * @jboss:table-name T_ORDER
            */
            public abstract class OrderBean implements javax.ejb.EntityBean {

            [...]

            /**
            * @ejb: pk-field
            * @ejb: persistent-field
            * @ejb:interface-method
            */
            public abstract Long getId();

            /**
            * @ejb:interface-method
            * @ejb:relation name="BookOrder" role-name="Order"
            * @jboss:relation-table table-name="BookOrder"
            * @jboss:relation related-pk-field="id"
            */
            public abstract java.util.Collection getBookList();
            }

            BookBean
            =======================================================

            /**
            * @ejb:bean name="Book" type="CMP" primkey-field="id" view-type="local"
            * @ejb: pk class="java.lang.Long"
            * @ejb:transaction type="Supports"
            * @ejb:home generate="local"
            * @ejb:interface generate="local"
            * @ejb: permission unchecked=""
            */
            public abstract class BookBean implements javax.ejb.EntityBean {
            /**
            * @ejb: pk-field
            * @ejb: persistent-field
            * @ejb:interface-method
            */
            public abstract Long getId();

            [...]

            /**
            * @ejb:interface-method
            * @ejb:relation name="BookOrder" role-name="Book"
            * @jboss:relation-table table-name="BookOrder"
            * @jboss:relation related-pk-field="id"
            */
            public abstract java.util.Collection getOrderList();
            }

            Kind regards, Wilfried Klauser


            P.S. Please note that I had to put a space between @ejb: and parameters starting with a "p", because it would be displayed as an emoticon otherwise