-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: merge() to re-attach entities and Cascade.ALL
PostPosted: Wed Nov 14, 2007 9:27 am 
Newbie

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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.