-->
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.  [ 3 posts ] 
Author Message
 Post subject: Updating a large object graph
PostPosted: Sat Jun 21, 2008 4:07 am 
Newbie

Joined: Wed Dec 19, 2007 6:49 am
Posts: 8
Location: London
Hi,

I have a large object graph in the database which a user may update by uploading a file. When the file is uploaded the data is parsed into objects. This object graph is then passed to hibernate and saved.

The problem is that the user may select to update their objects in the database with the file, so the parsed objects are transient, have PKs of 0, but those objects may reflect persistent objects.

In my equals() methods of those objects I have this, where id is PK -

Code:
if(this.id != 0 && that.id != 0)

.... then compare by id.....
....

....else compare by other values


However, hibernate does not find the reflected persistent object with the parsed transient one and I end up with two persistent objects with different PKs but the same values for the other fields.

Does hibernate just compare objects by PK?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 7:30 am 
Newbie

Joined: Wed Dec 19, 2007 6:49 am
Posts: 8
Location: London
solved it!

I was manually adding the parent objects to the children in my code when ever I added a new child!

Hibernate just works as it should now.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 10:30 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Awesome! Thanks for the update.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


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