-->
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: Inefficiency in org.hibernate.type.CollectionType replace()?
PostPosted: Mon Oct 16, 2006 4:32 am 
Newbie

Joined: Fri Feb 10, 2006 6:02 am
Posts: 15
I have an object graph as follows

Code:
Product
    |
    |----(many-to-one)----Address
    |                            |                                                           
    |                            |----(one-to-many)----AddressKeys (Set)
    |
    |----Name



When I call merge() passing in an already persisted product, with the product name different to the persistend name I expect only the version of the product object to be updated, and as a result only an update statement made to the product table in the database.

However, in reality the Address and AddressKeys get their version incremented as well and an update sql expression is therefore executed on their database tables.

I have debugged the hibernate code (3.2.0CR2), and also the head of CVS at the time of writing this. It appears that Hibernate thinks the AddressKeys collection is dirty and requires updating.

I think I have tracked down the culprit code inside org.hibernate.type.CollectionType at abount line 449 in the replace method, but as I'm no expert with the Hibernate code can someone confirm this is the cause.

Code:

   public Object replace(
         final Object original,
         final Object target,
         final SessionImplementor session,
         final Object owner,
         final Map copyCache)
   throws HibernateException {
                .....      
      if (original==target) {
         //get the elements back into the target
         //TODO: this is a little inefficient, don't need to do a whole
         //      deep replaceElements() call
         replaceElements( result, target, owner, copyCache, session );
         result = target;
      }
                ....
   }


It looks as though whether or not the collection has changed the elements are replaced and hence it is marked as dirtyand the versions are incremented.

Can someone please confirm whether this is correct and an inefficiency that is present at the moment.

Thank you

Adrian


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 19, 2006 8:24 am 
Newbie

Joined: Fri Feb 10, 2006 6:02 am
Posts: 15
Can someone have a look at this - I just need a yes or no answer.

Cheers


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 23, 2006 7:14 pm 
Newbie

Joined: Thu Jun 16, 2005 5:21 pm
Posts: 6
Check out http://opensource.atlassian.com/project ... e/HHH-2162 - it's right in the same area you're refering to.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 24, 2006 5:42 am 
Newbie

Joined: Fri Feb 10, 2006 6:02 am
Posts: 15
Thanks for the info!

I've voted and commented on the issue and hopefully it will get resolved.

At least now I can stop worrying about it and just wait for the fix rather than wondering if it is my problem.


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.