5 Replies Latest reply on Sep 4, 2002 2:30 PM by Paul Sabadin

    How to model CMR 1:2 (not 1:1 or 1:many)?

    Paul Sabadin Newbie

      I am building a weighted-directed graph with jboss and need your help with code and xml descriptors.

      Here's the logical model I am working on and the problem ...

      Node instance S links to Node instnce T. S is the source node, and T is the target node.

      S--->T

      However, the link itself has attributes (such as the frequency with which these nodes link) so that the link, L, is properly modeled as a first class entity. Thus,

      S--(L)-->T

      I WANT to model the entity Link L such that I can navigate to the source node S or the target node T through a CMR call on L such as,

      public abstract class L implements EntityBean
      {
      ...
      // WANT CMR getters and setters like this...
      public abstract NodeLocal getSourceNode();
      public abstract void setSoutceNode();

      // and
      public abstract NodeLocal getTargetNode();
      public abstract void setTargetNode();
      }

      The rub is that JBoss (deploy-time) will not accept the property setters and gives the following error:

      " Getter was found but,no setter was found for field: sourceNode (targetNode)]"

      How do I do this in JBoss???

      Much thanks for any brain cells burned on this problem

      Paul

        • 1. Re: How to model CMR 1:2 (not 1:1 or 1:many)?
          Jochen Cordes Novice

          Hi Paul!

          Hmm.. So basically you have two 1:1 uni-directional relationships with S and T for L ...

          I assume that the code-snippet is taken from the actual source. Based on the assumption I can say that there are at least three typos in there. It should look like this:

          public abstract class L implements EntityBean
          {
          ...
          // WANT CMR getters and setters like this...
          public abstract NodeLocal getSourceNode();
          public abstract void setSourceNode(NodeLocal sourceNode);

          // and
          public abstract NodeLocal getTargetNode();
          public abstract void setTargetNode(NodeLocal targetNode);
          }

          Hope it helps,

          Jochen.

          • 2. Re: How to model CMR 1:2 (not 1:1 or 1:many)?
            Paul Sabadin Newbie

            Thanks Jochen,

            Problem remains. The actual source code is as you state (setter args are correct). My source was in error as posted.

            The problem is THE NAMING of the properties! If I have only ONE uni-directional relationship AND NAME IT BASED ON THE BEAN TYPE <getNode() setNode(NodeLocal InNode)> it works! if I NAME the property <getSourceNode(), setSourceNode(NodeLocal InSrcNode)> it barfs on deploy with the error message as in the first post.

            ??? Must ALL relationship getters/setters ONLY be named with the BeanType. That is, do I have to say getBeanType()/setBeanType(BeanTypeLocal InMyBean) and NOT ...

            public abstract BeanTypeLocal getMyName();
            public abstract void setMyName(BeanTypeLocal InMyBean); // ???

            If so, then I can't name my propert ANYTHING BUT the name of the BeanType! Which suggests that this sucks!

            • 3. Re: How to model CMR 1:2 (not 1:1 or 1:many)?
              Dain Sundstrom Master

              > ??? Must ALL relationship getters/setters ONLY be
              > named with the BeanType. That is, do I have to say
              > getBeanType()/setBeanType(BeanTypeLocal InMyBean) and
              > NOT ...

              No. Did you declare both relationships? If you look at the commerce test in the JBoss Testsuite an Order has a ShippingAddress and a BillingAddress, which are both Address EJBs.

              • 4. Re: How to model CMR 1:2 (not 1:1 or 1:many)?
                Paul Sabadin Newbie

                I will chck this out and report back. It is very important for my application.

                Thank you for the quick response, Dain.

                • 5. Re: How to model CMR 1:2 (not 1:1 or 1:many)?
                  Paul Sabadin Newbie

                  Close this one out. My bad.

                  A better understanding of ejb-jar.xml and jbosscmp-jdbc.xml set right my misunderstandings.

                  Dain's CMP docs certainly help with this!

                  Thanks all - bye
                  Paul