java - Which layer do I 'hydrate' object graphs? -


i have persistence layer serves data many clients. have table structure normalized, means values spread across tables. want design persistence service ensure services depend on minimal round trips: not more one, if possible.

given this, should focus on elegant solution?
1. ensure clients can indicate portion of object graph want during fetch? (thereby reducing round-trips) [eg: fetch(parent, list<child-object-name>) ]
2. ensure provide common methods such hydrating portions of object, along basic fetches? [eg: hydrate(parent, list<child-table-name>)]
3. provide basic information start (for example, object graph depth 1 / look-up-table objects,) , rest upon request?

i understand, there many many discussion on net, information. did read few well:
* http://forum.springsource.org/archive/index.php/t-23439.html
* how can access lazy-loaded fields after session has closed, using hibernate? (answer paul adamson)
* deep object graphs hibernate

however, of answers hover 'do suits best'. programmers in situation?

don't make generic one-size fits-all persistence layer. write persistence methods functional use-cases you're implementing.

while doing it, you're going meet cases persistence method, or part of it, can reused across 2 or more use-cases. force rename method make more generic (less coupled 1 specific use-case), or refactor extract common part. if want best performance app, you're going need specific queries specific use-cases.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -