Discussions

EJB programming & troubleshooting: Doubt about object parameters and EJB

  1. Doubt about object parameters and EJB (3 messages)

    Hello folks, i will try to be brief:

      I have one object MyObject which i use as parameter to my beans's method, like:

      public class MyBeanEJB extends SessionBean {
        public void doSomething( MyObject obj_ )
        {
          //something here
        }
      }

      And

      public class MyObject
      {
        //Some code:
      }

      My problem is, every object that i use as parameter and or result from a method must implement Serializable?

      Regards,
      Edson
  2. My problem is, every object that i use as parameter and or result from a method must implement Serializable?

    Yes, they do. Unless it's a local session bean.
    That's the reason why paramaters should be of a light classes. Please also take into account that if you parameter include reference to another object, the referenced object will be also serialized.
    Please, have a look at Transfer Object pattern: http://java.sun.com/blueprints/corej2eepatterns/Patterns/index.html
  3. In remote call everything is passs by value so the object must be marshalled and unmarshalled.
  4. Objects sent on the network must be serialized (i.e. must implement Serializable interface).