3 Replies Latest reply on Jul 31, 2002 8:15 PM by dsundstrom

    CMR bug or misuse?

    rfrey

      I've been working through problems with persistence of CMR fields, very similar to those described in bug 523627. I've been using the excellent test case provided by Michael Newcomb to help me. Thanks, Michael!

      Anyhow, I've discovered that my code does not work because instead of creating the referenced object externally and passing it to the ejbCreate method, I'm passing a string ID and obtaining the actual local reference within ejbPostCreate.

      Using Michael's test case, I've found that the following works great:

      public void ejbPostCreate(String id, String description, TestuserLocal parent)
      throws CreateException
      {
      setParent(parent);
      }

      However, this snippet doesn't work at all. Note that calls to getParent made within ejbPostCreate, but after calling setParent, return the appropriate local reference.

      public void ejbPostCreate(String id, String description, String parent)
      throws CreateException
      {
      try {
      TestuserLocal tl2 =
      ((TestuserLocalHome)context.getEJBLocalHome()).findByPrimaryKey(parent);
      setParent(tl2);
      }
      catch(FinderException ex) {
      }
      }

      Am I abusing the creation methods by obtaining external references from within them, or is this a bug?

      Thanks!
      Rod.

        • 1. Re: CMR bug or misuse?
          rfrey

          A bit more floundering on my part indicates that CMR fields are *never* persisted with my configuration (Jboss3.0RC2, Mysql) if the CMR reference is obtained from within the bean itself. Going back to Michael's example, the test method

          public abstract void setParent(CMRbugLocal cmrbug);

          works like a champ, but when I overload the method:

          public void setParent(String parentID) {
          try {
          &nbsp&nbspContext c = getInitialContext();
          &nbsp&nbspCMRbugLocalHome clh = c.lookup("java:comp/env/ejb/CMRbugLocalHome");
          &nbsp&nbspCMRbugLocal cl = clh.findByPrimaryKey(parentID);
          &nbsp&nbspsetParent(cl);
          }
          catch(Exception ignored){}
          }

          the CMR field is set for the scope of the setParent(String) method (i.e., I can call getParent and get expected values on the CMRbugLocal returned), but the field is not persisted in the database.

          This seems somewhat crippling to me, as it precludes use of value objects for remote EJBs that have CMR references.

          My hope is I'm overlooking something obvious!
          Rod.

          • 2. Re: CMR bug or misuse?
            scornflake

            I have observed that exact behavior with the current 3.0.0 (to Oracle9i) release as well. Did you manage to find any solution to this?


            Regards,
            Neil Clayton

            • 3. Re: CMR bug or misuse?
              dsundstrom

              This is a bug in 3.0 that has been fixed, but I think the fix is not in 3.0.1rc1. I think you have to get 3.0 from cvs. There should be a 3.0.1 release soon (they are just waiting on some of my fixes).