It's an issue I'm thinking over at the moment as well. You could look at NH collection options such as "batch-size". This can drastically reduce the number of round-trips to the DB. Lazy loading as a default is a good idea, then remove it for those cases where it doesn't make sense (e.g. a customer object with a customer type object) to lazy load, as you virtually always need the other object.
My object model is as pure as I can make it, with some edge case situations where I might store a calculated value, then use NH mapping to tune the best I can. However, I have come across scenarios where I am assembling an aggregate (e.g. for a Service layer call). I've found it much more performant to dump the object model navigation and do as much as I can in HQL, maybe even use multi query to submit several in one batch, then convert the result into my special aggregate object directly. This is instead of returning business objects and navigating them through code to create the aggregate. It doesn't "feel right", as the object model is there to be used, not ignored when things get tricky, but I think its a problem with all ORMs. not just NH. The other scenario I really don't like is where I return several instances of an object, then navigate through them calling business methods. If these business methods call other objects that happen to need data, then I have a performance problem as each will submit seperate requests to the DB. I can't batch them up to hit the DB in one hit, as it all depends on what business logic is performed. The answer would be another aggregate object where I populate everything I could possibly need in one hit, but it really doesn't fit in this scenario and all you'd end up with is a load of aggregrates, an anemic data model and something similar to datasets. I don't have an answer this this last scenario yet, apart from to try to tune via the mapping files... if anyone else has any ideas, I'd be happy to hear them! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
