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: How to detect changed objects after session.Reconnect()
PostPosted: Tue Sep 04, 2007 1:05 pm 
Beginner
Beginner

Joined: Tue Sep 04, 2007 12:36 pm
Posts: 23
This seems to be a basic concurrency function, but I was having trouble finding any answer to my question elsewhere.

NHibernate V1.2

Consider the following scenario:

I have a smart client which loads a large amount of data, manipulates it in memory, and persists the changes when user interaction is finished.

The user loads object foo in a session

ISession session = NhibernateHelper.GetCurrentSession();
Foo foo = session.Get(typeof(Foo),id);
session.Disconnect();

<time goes by... foo is changed locally>
<call to to persist the changes>


session.Reconnect();

//before updating, check to see if any property of foo has changed in the database
if(foo has changed)
{
notify the user that foo has changed in the database
}
else
{
session.SaveOrUpdate(foo);
}

The current definition of a "stale" object seems to mean a key-property has changed, but I need to see both key and non-key property changes.

How do I check to see if ANY properties of an object have persisted changes before updating?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 05, 2007 12:40 am 
Regular
Regular

Joined: Tue Feb 21, 2006 9:50 am
Posts: 107
i track the changes in my persistent object via a 'hasChanges' flag which will be set to true in the setters of my properties. Then i wrote an interceptor which evaluates this flag.

Regards
Klaus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 06, 2007 2:01 pm 
Beginner
Beginner

Joined: Tue Jul 10, 2007 5:27 am
Posts: 34
Location: Belgium
if you can, use the version feature... it's a very nice way to deal with optimistic concurrency

_________________
Davy Brion
http://ralinx.wordpress.com


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.