Hi,
in my application i use only FetchType.EAGER. I want to change it into LAZY in result to gain more performance. My problem now is when i change it into LAZY i get an exception like
Code:
failed to lazily initialize a collection of role: .., no session or session was closed
Here my a part of my LogFile:
Code:
13:54:45,154 DEBUG JpaTransactionManager:534 - Closing JPA EntityManager [org.hibernate.ejb.EntityManagerImpl@c028cc] after transaction
13:54:45,154 DEBUG EntityManagerFactoryUtils:311 - Closing JPA EntityManager
13:54:45,154 ERROR LazyInitializationException:19 - failed to lazily initialize a collection of role: ...
So the problem is the EntityManager gets closed. This was no big deal before because with EAGER i suppose i was fetching the Objects i needed on initialization so within the Session. But now i only want to Fetch them when i really need them. How can i tell spring to reopen it (session / entitymanager) when i need it?
i hope somebody can help me thanks in advance ;).
edit: i've tryed to add em.getTransaction.begin() before my CRUD's but i get an exception because i'm using a shared EntityManager and it says i have to handle it by Spring.
greetz kuku