-->
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.  [ 2 posts ] 
Author Message
 Post subject: Question on Hibernate behavior
PostPosted: Tue Mar 02, 2010 7:13 pm 
Newbie

Joined: Tue Oct 04, 2005 4:08 pm
Posts: 3
I'm running into a behavior related to hibernate while trying to update a child object. I've a version column property implemented for optimistic locking. I'll try to illustrate the issue by the following example.

Lets say I've a Company parent object . It has couple of child collection, Office, Inventory and Employee. Lets say, Office has a child entity Address. In this scenario, I'm trying to add a new Employee to the parent collection. After adding it, I noticed that hibernate has fired an insert for the new record as well couple of updates to increment the version number of Company and Office object. What baffled me is that why hibernate is updating the version of Office when adding an Employee. But it didn't update the version property of Inventory. On further research, I found that the version update happens for the sibling having a child. In our case, Office is getting updated since it has a child collection i.e. Address. At the sametime, update doesn't happen for Inventory since it doesn't have a child.

I'm not sure if this is how hibernate is supposed to behave. I've tried looking into the documents but unable to find anything worth. This unrelated updates is causing a performance overhead when I'm dealing with a batch of large collection data.

Any pointers will be highly appreciated.


Top
 Profile  
 
 Post subject: Re: Question on Hibernate behavior
PostPosted: Wed Mar 03, 2010 6:49 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
I'm not sure if this is how hibernate is supposed to behave.


I think not.
There' should be only an update to increment the version number of Company.
Try to use a newer version of hibernate.
I that not help, debug the code putting a breakpoint at EntityUpdateAction constructor.
This should help you find out who is triggering the UpdateAction on Office.


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