I am working with an application which consists mainly of Spring, JSF, and Hibernate. I'm trying to come up with some guidelines and would like to get some feedback. The typical pattern is to list records in a datatable, you click the row, then pick some option (eg. Update/View, etc...). I am calling load() in the setSelectedXXX method of the ManagedBean/View Model, via the DAO which just delegates to Session.load(), but it seems that it causes problems related to page reloads. I had considered calling load() from getSelectedXXX, but am unsure if that approach is considered "good" because it will be called many times when the page is being rendered. I decided to tweak the load() method of my DAO to first check if the object is already associated with a session, and load if not, otherwise, just return the object. So... 1. Should I just make the call to load() in getSelectedXXX instead? 2. Is there any benefit in checking for a session before calling Session.load()?
|