-->
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: Nhibernate updating all columns instead of updated ones only
PostPosted: Tue Apr 04, 2006 7:53 pm 
Beginner
Beginner

Joined: Mon Sep 26, 2005 5:57 pm
Posts: 39
I have noticed that when I update a single property of an object and call save, the resulting SQL statement includes all the columns instead of the one that I just touched.

Is this expected or is it something I am doing incorrectly.

Some of the columns in my table are 'text' columns, so the update statement that is generated is huge. Is there some way I can avoid this, and just have Nhibernate update the columns whose respective properties are dirty?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 04, 2006 10:56 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
It is expected. If you want to conditionally update certain columns, I recommend putting all the rarely-updated properties in their own class, and mapping that class via a one-to-one association, with cascade="all". If you don't edit the those objects, then isDirty won't notice them and they won't get saved.


Top
 Profile  
 
 Post subject: Re: Nhibernate updating all columns instead of updated ones
PostPosted: Wed Apr 05, 2006 2:43 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
jbliss1234 wrote:
Some of the columns in my table are 'text' columns, so the update statement that is generated is huge. Is there some way I can avoid this, and just have Nhibernate update the columns whose respective properties are dirty?


You might try to add dynamic-update="true" to You class mappings.

Gert


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 05, 2006 5:21 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
implement 'finddirty' in an interceptor.. pass it the dirty columns and your good to go. Use in combination with gerts advise


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.