Joined: Tue Oct 16, 2007 5:45 pm Posts: 4 Location: Poland
|
Hi!
I use JPA with a JSE web-application. I have an EntityManager on demand for each thread (using the JPAUtil with ThreadLocal EntityManager). The thread-local entity manager is closed by a filter after every request. The problem is with entities being in the session - one request puts it there, then it is detached and another request might want to use it. Because everything is lazy fetched I re-attach the entity by calling em.merge(myEntity). Since some relations are annotated with Cascade.ALL, it calls a huge amount of SELECT's (one for each entity in the Collections with Cascade.ALL). Is there any possibility to avoid this other than disabling Cascade? (I need it in other places of my app). Or maybe the whole approach is wrong?
Thanks in advance.
|
|