开发者

Deep Object Graphs Hibernate

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开发者_StackOverflow中文版 decrease the depth and increase the number of DAOs. It seems to me this must be a common trade-off, is this reckoning correct?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜