Hi,
I have an application in which I am using JPA over Hibernate. I have a class named Employee and an associated collection of List<Address> addresses(I have specified this as LAZY). When the Employee page is taken to be edited through UI, I put Employee object in HttpSession. When the user makes changes on UI and submits, I get these changes made reflected on the Employee object in HttpSession(I am using Spring MVC for this). Now, when I try to update the Employee object using EntityManager.merge(), its firing n+1 queries to first fetch the list of addresses and then it does the update. I want to avoid these n+1 queries for they are affecting the performance of the application. I feel when I retrieve the Employee from HttpSession, it will be detached.
I do not want to use an OpenSessionInViewFilter for I do not want lengthy Hibernate sessions. Can anyone suggest a solution for this?
|