Hi All,
I have a question related to fetching an associated entity.
There are two tables/entities.
1. Person and
2. PersonStatus
Mappings are as follows.
Person Entity:( In the table, I have a column person_status marked as a FK to Person_Status.PersonStatusIDCode:
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "PERSON_STATUS_KEY")
public PersonStatus getPersonStatus() {
return this.personStatus;
}
PersonStatus:Code:
private Set<Person> persons = new HashSet<Person>(0);
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "personStatus")
public Set<Person> getPersons() {
return this.persons;
}
Problem: When I fetch the Person entity, I do not get the associated PersonStatus loaded into the person instance. Even after I call Code:
person.getPersonStatus().
The person table has a valid FK value, I expect getPersonStatus() to load an instance of that type with the Person entity.
Could someone please point where I have gone wrong?
Thank you