-->
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.  [ 1 post ] 
Author Message
 Post subject: <many-to-one> FK(SSN) is null when I call getSSN().
PostPosted: Wed Apr 25, 2007 12:33 pm 
Newbie

Joined: Thu Mar 08, 2007 12:59 pm
Posts: 9
All,

I have a bidirectional Parent/Child association.


Code:

This is Parent, Person:

<set name="employers" table="EMPLOYER" cascade="save-update"  inverse="true" lazy="true">
      <key column="ssn"/>
      <one-to-many class="org.xxx.Employer"/>
   </set>

This is Child, Employer:

   <many-to-one name="Person"
       column="SSN"
       not-null="true"
       class="org.xxx.Person"/>

and Employer.java

private String ssn;
private Person person;

/*
*This returns null, but I want to keep it this way if possible.
*/
public String getSsn(){
return ssn;
}

/*
* This works, but SSN is from after referencing the parent object.
*/
public String getSsn(){
return person.getSsn();
}


Everything is working fine. all data stored correctly to both parent and child table.

But Only one thing I can't figure it out is...

when i call getSSN() from child object, it returns null even thou actual table has SSN value. However I can do this. getPerson().getSSN().

Code:

child.getSSN(); // returns null.
child.getPerson().getSSN(); //returns correct SSN, its coming from parent.


But I want to make this

child.getSSN(); //getSSN(){return ssn;}

to work too. without modify getSSN() method




Is this ever possible?

Thank you in advance.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.