-->
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: Hibernate does not update *some* objects
PostPosted: Wed Jan 02, 2013 8:00 am 
Newbie

Joined: Sat Jan 27, 2007 2:03 pm
Posts: 6
Location: Dallas, TX - USA
I have recently noticed something weird while updating a few objects. I have the exact same path of code that runs for either objects. However, for a few objects I have observed that consistently their parent-child is not updated. That is, the child of the relationship is not updated during a persist. I am using JPA/Hibernate with proper cascade, and I call persist on the entity manager.

For some others the parent-child relationship is updated properly. And I am running the *EXACT* same code and going thru the *EXACT* same code path for either objects.

I noticed in the logs, that for the object whose child is not updated, the ID is not updated, example:

com.softlagos.domain.address.PhoneNumber@404c0224[
id=-1 < --- object ID is not updated
version=<null>
type=BUSINESS
phoneNumber=21-2222-4444

However, for the objects whose child is updated, the child object id is updated:

[com.softlagos.domain.address.PhoneNumber@5ed1330[
id=2294 < --- object ID is updated
version=8
type=MOBILE
phoneNumber=222222

I have already enabled all logs, and I cannot determine the origin of the problem.

I am running MySQL on Linux, and latest hibernate libraries: 3.6.9.Final

Any clues?

Rubens.

_________________
--
Rubens Gomes
www.rubens-gomes.com


Top
 Profile  
 
 Post subject: Re: Hibernate does not update *some* objects
PostPosted: Wed Jan 02, 2013 11:14 am 
Newbie

Joined: Sat Jan 27, 2007 2:03 pm
Posts: 6
Location: Dallas, TX - USA
This issue appears to be related to not setting parent-child relationships. For objects whose child records were previously created (inserted), the updated worked. However, if the child records were not previously created, the update failed.

Adding the parent.add(child), child.set(parent) relationships in the code fixed this issue.

Rubens.

_________________
--
Rubens Gomes
www.rubens-gomes.com


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.