-->
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: objects getting updated to database on select Query(Fetch)
PostPosted: Wed Jan 09, 2008 1:49 pm 
Newbie

Joined: Wed Nov 21, 2007 8:03 am
Posts: 2
Hello there;

Can some body explain if this is the expected behavior,

I am reading a record for update (displayed on GUI). During this update process (before making final update call) I am trying to fetch all the records from the same table to which my record belongs, but before fetching this process is initially committing my object changes to Database and then fetching the whole table , so my object gets updated to database table even i f I have not made final update call. Can you tell me how can prevent this from happening?.

Thanks in advance :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 1:55 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
The session will flush to ensure that you get fresh data from database, take a look in the nhibernate reference manual chapter 9.6.

One way to avoid this in your situation would be to evict the object to disable change-tracking for it before fetching the collection, but somehow that doesn't feel right


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 09, 2008 4:55 pm 
Expert
Expert

Joined: Tue Aug 23, 2005 5:52 am
Posts: 335
The normal approach here is to wrap the functionality within the session in a transaction so these writes can be done as required. If you want the whole change you commit, otherwise you roll back.

In the event that you don't want to roll back you can have some kind of compensation code that will re-modify the state of your object so it's back the way you want it before your commit.

Cheers,

Symon.


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.