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.