2 Replies Latest reply on Jul 5, 2002 11:47 AM by E. A. Graham Jr.

    If CMR are not exposable to Remote clients, then how....?

    Travel Maniac Newbie

      If CMR fields are not exposable to remote clients then how can a remote client get that info? Say I have a 1:N relationship between a user and its projects. I have a remote client like an applet. It manages to get a remote ejb object of type User. Then it wants to get a list of projects, but that list is gotten through the cmr field. So does that mean that I need to write a separate function that creates another list of remote clients based on the list of local clients inside the UserBean class?

      Sounds twisted, no?

      G

        • 1. Re: If CMR are not exposable to Remote clients, then how....
          Lance Cranford Newbie

          >So does that mean that I need to write a separate function that creates another list of remote clients based on the list of local clients inside the UserBean class?

          Yep

          > Sounds twisted, no?

          Yep. I guess they implemented CMR this way because of speed. A relationship with remote objects have the potential to have serious performance problems. But that should be left up to the architect of the app instead of the spec, IMHO. But here's a way to get around this restriction:

          public Collection getRemoteProjects() throws EJBExcpetion
          {
          Iterator iter = getProjects().iterator();
          Collection remoteProjects = new ArrayList();
          while(iter.hasNext())
          {
          ProjectLocal projectLocal = (ProjectLocal)iter.next();

          ProjectRemote projectRemote = projectRemoteHome.findByPrimaryKey(projectLocal.getPrimaryKey());

          remoteProjects.add(projectRemote);

          }

          Hope that helps,

          Lance

          • 2. Re: If CMR are not exposable to Remote clients, then how....
            E. A. Graham Jr. Newbie

            Actually, it would probably be better (at least that I've found) to use a Stateless SessionBean as a "front-end" to the EntityBeans (thereby accessing those via locals) and transfer serializable data objects (DOs) back and forth across the wire. The DO of the primary object contains collections of child DO objects and these map to the EntityBeans. The SLSB does the translation/validation between DO and EntityBean.