DTO having another DTO

Discussions

EJB design: DTO having another DTO

  1. DTO having another DTO (3 messages)

    Is it a good idea for a DTO to have another DTO - design-wise or are there any pitfalls to this?
    for example,

    EmpID_DTO {
         String id1;
         String id1;

         // other ID related fields .....
         // .....

    }

    EmpDTO{
         String Name;
         Date DOB;
         EmpID_DTO IDs;

         // other ID related fields .....
         // .....

    }



    -PI

    Threaded Messages (3)

  2. DTO having another DTO[ Go to top ]

    Hi P-

    I employ a heirarchical DTO structure in a project I'm working on now. My only suggestion is to beware of cyclical relationships. Remember, the point is to present coarse-grained views of finely grained data. In short, I think it's ok.

    HTH,

    P
  3. DTO having another DTO[ Go to top ]

    I am also using a similar pattern in my project. In my case, each DTO has a Collection of other DTOs. When calling my EJB "getter" for the "root" object in this hierarchy, I indicate whether or not I want these Collections populated.

    Obviously, I would prefer to lazy load these collections, but I was unable to come up with an appropriate way to do this and still maintain the spirit of the TransferObject design pattern -- it rather defeats the purpose if my data transfer object needs to access live model data to do its job.

    See this thread for more information on my situation: http://www.theserverside.com/discussions/thread.tss?thread_id=32284
  4. thanks[ Go to top ]

    Thanx for your replies.
    -PI