-->
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.  [ 4 posts ] 
Author Message
 Post subject: How-to update only two fields?
PostPosted: Fri Feb 29, 2008 6:01 am 
Newbie

Joined: Tue Jan 22, 2008 4:43 pm
Posts: 7
What if I have an object with several properties:

obj.Product
obj.Customer
obj.From
obj.To

and normally I want to update all these properties but in some cases I only want to update From and To (even if the other fields have changed).....

Which is the best way to do this?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 6:22 am 
Beginner
Beginner

Joined: Tue Mar 27, 2007 4:54 am
Posts: 47
As far as I know, this is not possible out of the box in current version. You have to handle it yourself by resetting org values in your object or implement in further down, eg in an interceptor.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 10:11 am 
Regular
Regular

Joined: Tue Dec 25, 2007 3:41 pm
Posts: 57
Location: Argentina
Hi,

When you do a .BuildSessionFactory(), NHibernate create the sentences Update/Insert/Delete onto command-objects ready to execute against the base, and this never change at least you are using versioning at entity. And this is a cool feature.

Is very important to you only go to Db only with the properties changed ?

Best regards

_________________
Dario Quintana


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 10:16 am 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
The problem is that the original poster want to save selected properties only even though some of the other changed. To accomplish what you describe you could use dynamic-update and dynamic-insert in your mapping so only changed columns will be part of the UPDATE/INSERT statements


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