I work on the Hibernate / JPA / Spring / Zk architecture, and these days I multiply the questions because I need to learn a lot of frameworks.
I have a question that leaves me puzzled for several days.
I heard about the OpenSessionInView "template" to support the Hibernate transaction for lazy loading. Many also say that the template is not very clean.
And on the other hand, it is said that the extended PersistentContext is not thread safe and therefore not suitable for saving the entityManager.
So what is the real solution to these problems? I assume that these problems arise because of the introduction of ajax, which allows more options, especially when using lazy loading to load heavy collections if necessary.
At the moment, I have tried @PersistenceContext in advanced mode. It works ... I had to install it for my JUnit tests, and it also worked in my web application with lazy loading without additional configurations.
Is this because the evolution of the structure (Spring, JPA 2.0) means that it is now easier and more “clean” to work with PersistentContext?
If this is not the case, should I use OpenSessionInViewFilter from Spring and replace the PersistentContext in transactional mode?
Thank.
source
share