-->
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.  [ 3 posts ] 
Author Message
 Post subject: one merge cause multiple updates
PostPosted: Thu Feb 26, 2009 6:46 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
Hello
Sometimes Hibernate (despite not launching "merge") update entity.
In application there is a few methods which changes record, and at the end of transaction (JBoss manages transaction) there is EJB component which calls em.merge.
But Hibernate sometimes save changes earlier. What is worse, some of this updates do nothing (sets previously setted value)
I know, thet Hibernate can do update whenever it wants. But is there possibility to forbid that?
I would like to force Hibernate to make updates only whene merge is called. Is it possible?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 27, 2009 6:57 am 
Beginner
Beginner

Joined: Thu Feb 28, 2008 4:58 am
Posts: 37
Any help?
Can FlushMode be used to do that?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 02, 2009 5:36 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
Sounds like you are making your changes inside a container (JBoss), so your entities stay managed while doing this. Changes to managed entities are flushed automatically at transaction end.

You could avoid that by detaching them (((Session) entityManager.getDelegate()).evict()) which is not the nicest solution or by managing your Transactions manually (Look at the @TransactionAttribute annotation).

_________________
-----------------
Need advanced help? http://www.viada.eu


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

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.