-->
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.  [ 2 posts ] 
Author Message
 Post subject: UPDATE after INSERT on session flush
PostPosted: Fri Mar 19, 2010 9:35 am 
Newbie

Joined: Fri Mar 19, 2010 9:16 am
Posts: 1
If we save a new transient object with session.persist(...) followed by a flush afterwards a single INSERT-statement is executed as expected. But if the object's properties are changed between the session.persist(...) and flush an INSERT followed by an UPDATE are executed on flushing the session. We expect that only a single INSERT would be necessary to persist the entity instead of two statements.

Is this behaviour desired and what are the reasons for this.

BTW: We use manual flushing with long running conversation on disconnected session.

Thanks
Stefan


Top
 Profile  
 
 Post subject: Re: UPDATE after INSERT on session flush
PostPosted: Mon Mar 22, 2010 4:02 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
Is this behaviour desired and what are the reasons for this.

From my experience it is Hibernates 'write-behind' mechanism that works in this way.
When persisting a new object, an insert-event is queued with objects' snapshot of that moment of persisting.
Further changes on that object are then propagated with an update-event.

Quote:
Is this behaviour desired and what are the reasons for this.


I assume it's desired, but unfortunately I don't know the reasons behind.
(In order to avoid the update, I already fill all properties with the final values before persisting the new object.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.