Hello everyone,
I have the following issue, that I already spent a couple of hours on:
Scenario:
I have a class Person that is subclassed into father and son.
The Person class holds a list of Person class (all the relations a Person has)
Code:
public class Person{
//yada yada yada
private List<Person> children = new List<Person>
private List<Person> parents = new List<Person>
@ManyToMany(fetch=FetchType.LAZY)
@IndexColumn(name = "children_INDEX")
public List<Person> getChildren() {
return children;
}
public void setChildren(List<Person> children) {
this.children= children;
}
@ManyToMany(mappedBy="children", fetch=FetchType.LAZY)
public List<Person> getParents() {
return parents;
}
public void setParents (List<Person> parents ) {
this.parents = parents ;
}
//yada yada yada
}
The mapping is working as expected, however when obtaining the list of parents or children, the individual entities are always of type Person and never of the correct subtype (i.e father or son).
I am using the inheritance strategy joined.
Any suggestions of how to have the lists populated with the actual subclasses are highly appreciated.
Thanks,
Steve