2 Replies Latest reply on Jan 22, 2003 11:43 AM by chavan

    Complex aggregate objects as entity beans?!?

    davout

      A newbie question about modelling complex objects as entity beans...

      Take the following project/phase/task example...

      class Project {
      private Vector fPhases;
      private fName
      int getPhaseCount()
      Phase getPhases(int idx)
      void addPhase(Phase aPhase)
      String getName();
      void setName(String aValue)
      }

      class Phase {
      private String fName;
      private int fOrder;
      private Vector fTasks;
      int getTaskCount()
      Task getTasks(int idx)
      String getName();
      void setName(String aValue)
      void setOrder(int aValue)
      void addTask(Task aTask)
      }

      class Task {
      String fName;
      int fID
      String getName();
      int getID();
      void setName(String aValue);
      void setID(int aValue)
      }

      If I setup 'Project' as an entity bean and I use CMP, for a 'find()' call will the CMP manager load the entire project/phase/task structure into the newly created instance or what? Is it possible to have the phase and task sub areas loaded on demand?

      Alternatively is this the right approach for EJB?

        • 1. Re: Complex aggregate objects as entity beans?!?

          if you're using the JBoss CMP2 engine you can define in your configuration which parts are loaded during find, which are lazy loaded etc. More info on the CMP forum and Dain's CMP2 documentation.

          • 2. Re: Complex aggregate objects as entity beans?!?
            chavan

            A follow up Question, how would you have saves so that the save of the Project causes Phases and Tasks to be batch saved instead of hitting the DB once per task + once per phase + once for the project. Also is there a way so that is only one phase changes then the store will only save the on Phase and all it's tasks

            thnx
            Chavan