I'm just starting out on my first rich client app (using Eclipse RCP client connecting to EJB3 and/or Spring and Hibernate back-end) and one of my first requirements is to display a tree view of an object hierarchy.
My top-level objects of type ClassA each contain a collection of objects of type ClassB, which in turn each contain a collection of objects of type ClassC, which in turn each contain a collection of objects of type ClassD, which in turn each contain a collection of objects of type ClassE. However, we are only likely to have a maximum combined total of perhaps one or two hundred objects.
My question is: What should I pass back to the client from the server? Do I want to pass back a complete object structure of Hibernate domain objects? Or would I be better off passing back an equivalent hierarchy structure of DTOs that just contain the ID and decription which I need in order to create the tree view?
It seems like extra work and unnecessary duplication to create a parallel hierarchy of DTO objects - but it seems inefficient to pass back the whole domain object hierarchy just to populate the tree...
If DTOs are the correct way to go, then would you also map these these in Hibernate? Is it ok to have DTOs (which are read-only) mapped to the same tables/entities as your domain objects? Or would you recommend not mapping the DTOs in hibernate and instead have them obtain the information they need from their matching Hibernate-mapped domain objects?
Any help here would be greatly appreciated!
Thanks in advance,
Lawrie
|