-->
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.  [ 6 posts ] 
Author Message
 Post subject: Parent Key Dropped
PostPosted: Sun Oct 15, 2006 12:12 pm 
Newbie

Joined: Wed Aug 16, 2006 1:13 pm
Posts: 9
Location: Oklahoma
When saving on the child object (many-to-one-side), the parent key (fk) is being dropped. Can someone tell me why? This doesn't seem right. And, I think my xdoclet mappings are fine. I can load the data prior to the test and I can obtain the children perfectly from the parent side.

But, when I modify and save the child, the parent-key is removed and made null.

Code:
   /**
    * @hibernate.bag table="account_detail" cascade="save-update" lazy="false"   
    * @hibernate.key column="account_id"   
    * @hibernate.one-to-many class="org.dlw.model.AccountDetail"
    */
   public List getAccountDetails() {
      return accountDetails;
   }


Code:
   /**
    * @hibernate.many-to-one class="org.dlw.model.Account" column="account_id"
    */
   public Account getAccount() {
      return account;
   }

_________________
Piratepete
david.whitehurst@wisplinx.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 12:37 pm 
Newbie

Joined: Wed Aug 16, 2006 1:13 pm
Posts: 9
Location: Oklahoma
And, don't ask for a stack trace. No error, just null parent key.

_________________
Piratepete
david.whitehurst@wisplinx.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 4:33 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
Without more information I can't tell you what's wrong.

But the most likely cause is that something is inadvertently setting the account to null when you're updating the account details.

I'd recommend whacking a debug point or println just before the update is flushed (most likely the transaction commit) and just check that the account is actually set to a non-null value.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 10:12 pm 
Newbie

Joined: Wed Aug 16, 2006 1:13 pm
Posts: 9
Location: Oklahoma
EdC:

I've narrowed it down to the fact that when I am in the JSF backing bean and I get the child object using a service manager, I tried to get the id of the parent and was going to try to get the parent as well using another managed property for the parent manager. When I call the method child.getParent().getParentId ... I find that the parent object is null, all the other properties on the child are there.

Why would the parent be null when the dao and service obtain the child object. And, if I use the other manager (another page) to obtain the parent, I can get the children and render those objects just fine.

I'm stumped. The save was failing with TransientObjectException (parent object) when saving the child. And, now I find that the parent object is null. I don't know why.

piratepete

_________________
Piratepete
david.whitehurst@wisplinx.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 15, 2006 10:34 pm 
Beginner
Beginner

Joined: Tue Sep 26, 2006 11:46 pm
Posts: 33
Don't know enough about JSF to really help with this. But I suspect you'd find that within the DAO the parent is set but something is setting it to null.

I tend to put a debug point within the set method to track down these kinds of problems so you can see where it's set to null.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 16, 2006 1:55 am 
Beginner
Beginner

Joined: Fri Aug 12, 2005 7:05 am
Posts: 25
Location: TamilNadu
Try with inverse="true" in set tag of your mapping document.

Regards
Shanmugam.N


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