2 Replies Latest reply on Jun 21, 2003 4:16 PM by vgamerma

    Do local EJB truly return objects by reference?

    vgamerma

      Hello,

      Do local EJB's return objects by reference or by
      value? I know they are not being serialized but for
      some reason if I modify a property of an object
      returned (and owned) by a local EJB the data in the
      object within the local EJB does not change.

      I read the spec I thought that I am clear on it so I tried the following code below...

      To illustrate:

      public class MyBean implements javax.ejb.EntityBean {
      B b = null;

      public B addB() {
      b = new B();
      return b;
      }

      public B getB() {
      return b;
      }
      }

      MyBean is deployed as a local bean.
      B class is NOT serializable.

      public class AnotherBean .... {
      public void blah-blah {
      .......
      B b = myBean.addB();
      b.setMyField(1);
      ........
      b = myBean.getB();
      // at this point b.getMyField() should return 1
      // but it does not. Is it expected behavior?
      .......
      }
      }

      Does JBoss cimply clones the B before returning it from the myBean?

      Thanks in advance.

      Val.