5 Replies Latest reply on Apr 30, 2002 11:56 PM by Dain Sundstrom

    Circular CMR

    James Hicks Newbie

      Has any got a circular cmr working in JBoss 3.0 rc1?

        • 1. Re: Circular CMR
          Dain Sundstrom Master

          What do you mean by a curcular cmr?

          • 2. Re: Circular CMR
            L Nowak Newbie

            If I understand it: making relation from one Entity CMP Bean to itself? I think it is a good question. I've got the same problem. (I need object tree) Is it possible?

            • 3. Re: Circular CMR
              Dain Sundstrom Master

              It works fine for me. Are you using RC1?

              • 4. Re: Circular CMR
                James Hicks Newbie

                Im using rc1 with Postgresql. I have ProductEJB that references itself. Ive tried the first 3 commit options (A,B,C) and several different combinations of transactions. I have tried passing the pk of the child to the parent where the parent does a lookup and gets an instance to the child, then sets the CMR field. Ive also tried just creating my parent first, then from the slsb calling the setCMR field on the parent with a local reference to the child

                My environment is the default (without tomcat), with the exception of postgres.

                My design is application -> remotesession -> localentity

                How are your beans designed/configured?

                I can actually post the code sometimes tonight when I get home.

                • 5. Re: Circular CMR
                  Dain Sundstrom Master

                  Say you have an emplyee has a supervisor and subordinates relationship. You would have the folling accessors int the employee object

                  public abstract Employee getSupervisor();
                  public abstract void setSupervisor();
                  public abstract Collection getSubordinates();
                  public abstract void setSubordinates();
                  

                  Right? Declare the relationship in the ejb-jar.xml file.

                  Then in your client code you do the following:
                  Employee myBoss = EmployeeHome.creat("Boss");
                  Employee me = EmployeeHome.creat("Boss");
                  me.setSupervisor(myBoss);
                  

                  Of course you have to do this on the serverside. Just put the code in a session bean.