-->
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.  [ 5 posts ] 
Author Message
 Post subject: Version and dateupdated got modified though no columns updat
PostPosted: Wed Oct 01, 2008 4:11 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
Hibernate updates the record though there are no changes to the fields. I have used dynamic-insert and update property to check what properties being modified; I have only found version and dateupdated getting updated. Any ideas what this is happening?

How does hibernate decide whether a record needs to be updated or not.

I really appreciate if some one could help me out.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 2:00 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
This could for example happen if your object has collections of other objects/entities and if you add or remove to/from those collections.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 1:38 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
Hi nordborg,

I really appreciated your reply. I did not have any changes to the child as well except that we are using a java bean mapper to map objects. After mapping, we did not have any fields being modified and the child values are all the same. In fact there was no update on the child, but the parent is getting updated with the next version. What i had found was that persistentset gets dirty though there were no changes to the child.

Any ideas when the persistentsets gets dirty?

I will look forward for your response.


Thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 2:07 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Are you returning the same Set instance from the getter method that Hibernate set on the setter method? Eg.

Code:
public void setSomething(Set something)
{
  this.something = something;
}
public Set getSomething()
{
   return something;
}


I have seen lots of examples of people doing copies of sets with, for example, the Set.addAll() method and other variants. This makes Hibernate to assume that it's dirty and Hibernate can in the worst case first delete all relations, and the re-create them again. My advice is that you turn on some logging to see what is going on. If you still can't figure things out, please submit relevant mappings documents and parts of your code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 02, 2008 2:14 pm 
Beginner
Beginner

Joined: Thu Oct 25, 2007 1:21 pm
Posts: 29
Again, I am very thankful to you.


I will do by enabling logging.

In that case, it should do an update, delete or create in the child table, right? Actually there were no sql statements excecuted on the child table except the parent table versioing incremented.

what I really do not understand is when there are no changes to the fields, why it does the update on the parent.

Even if there are any changes to the child, only the child should get updated, but not the parent. How do I impose this rule?

Thanks a lot.


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