The situation is this:
- You have a Hibernate context with an object graph that has some lazy loading defined.
- You want to use the Hibernate objects in your UI as is without having to copy the data somewhere.
- There are different UI contexts that require different amounts of data.
- The data is too big to just eager load the whole graph each time.
What is the best means to load all the appropriate objects in the object graph in a configurable way so that they can be accessed without having to go back to the database to load more data?
Any help.
Let’s say you have the Client and at one point you have to something with his Orders and maybe he has a Bonus for his Orders.
Then I would define a Repository with a fluent interface that will allow me to say something like :
And there you have the client with everything you need. It’s preferably that you know in advance what you will need for the current operation. This way you can avoid unwanted trips to the database.(new devs in your team will usually do this – call a property and not be aware of the fact that it’s actually a call to the DB)