-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to enforce Hiber. to update only col.that were changed?
PostPosted: Thu Dec 16, 2004 8:33 am 
Beginner
Beginner

Joined: Mon Feb 09, 2004 6:43 am
Posts: 35
Hibernate version:
2.1.6
Database:
Oracle 9.2.05

Hi
I have following problem.
We have object Contract that maps to Contract table. This object and table has around 60 columns. We process this table in following sequence:
- we read this column to Contract object
- we modify attributes in this object
- and we call hibernate update method for this object.

We have notice that Hibernate try to update all columns in database not only these columns that were updated. It is not good because when few rows are updatated (even if values are not changed) DB engine tries to rebuild indexes that were created on this columns.

How to enforce that only changed attributes will be updated ?

Regards
Michal


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 8:38 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
use dynamic-update


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 6:16 pm 
Newbie

Joined: Thu Dec 16, 2004 6:11 pm
Posts: 3
I'm having the same problem. Whenever I do a updateOrSave, it will update every object in the collection. I try to use the dynamic-update on the class, but that doesn't seem to make any difference. Please let me know if anyboday make it to work. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 6:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Does not work for detatched objects - probably will in combination with select-before-update=true


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 9:29 pm 
Newbie

Joined: Thu Dec 16, 2004 6:11 pm
Posts: 3
But a select-before-update will probably give poor performance. I'm wondering if there is a way that I can set a flag on the element of the collection, and hibernate detemine if the element needs to be update or not base on the flag that I set, or some interface I can implement with my class to do that? Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 16, 2004 9:33 pm 
Newbie

Joined: Thu Dec 16, 2004 6:11 pm
Posts: 3
Can you tell me what do you mean by deattached object? Thanks.


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