I understand that this is highly specific to the concrete application, but I’m just wondering what’s the general opinion, or at least some personal experiences on the issue.
I have an aversion towards the ‘open session in view’ pattern, so to avoid it, I’m thinking about simply fetching everything small eagerly, and using queries in the service layer to fetch larger stuff.
Has anyone used this and regretted it? And is there maybe some elegant solution to lazy loading in the view layer that I’m not aware of?
Lazy loading is only beneficial if you aren’t going to use the data in question at all (e.g. showing only a list of customers, hereby ignoring the nested set of orders), or if it’s not to be decided yet whether the user would like to view the data in question (e.g. having a list of customers in memory and the request for list of orders depends on future actions).
If you’ll for sure show all the data at once, then lazy loading is not needed, it would only cost an extra query.