views:

38

answers:

1

Our domain model is very tightly coupled and some classes that are mapped with hibernate are 6 collections deep. Currently we don't use lazy loading for these since the business layer passes some of the higher level classes around and retrieves some of their lower level children at which time the session will have been closed. Retrieving such a large amount of data to populate this object graph seems expensive and I have doubts as to whether the domain model is correct - perhaps we should decrease the depth and increase the number of DAOs. It seems to me this must be a common trade-off, is this reckoning correct?

+1  A: 

Yes, it is a common trade-off. I try to limit the maximum number of 1:n associations from an entity as much a possible. It's a lot easier to manually query the associated entities (making use of optimized queries) and creating a data transfer object to re-establish the associations into a complex object graph.

perdian