I would like to find a way to form a OneToMany relationship to objects that are retrieved from the child tables of an inheritance structure. For example I have a table, Shape, that represents the super class of the inheritance structure. In the java class for Shape it includes the annotation @Inheritance(strategy=InheritanceType.JOINED). I then have tables that represent the subclasses of Shape, these include Circle, Rectangle and Triangle. The java classes for each of these extend Shape.
I would like to find a way to form a OneToMany from another table/class called DrawingArea with syntax similar to:
Code:
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@JoinColumn(name = "SHAPEID", nullable = false)
public List<Shape> getShapes() {
return shapes;
}
This would return shapes of all types, Circle, Rectangle and Triangle where the primary key SHAPEID matches. How can I do this?