I have something like the following code snippets.
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class JobOrder implements Serializable{
@Id
public String Id;
@ManyToOne
public Occupation occupation;
....
}
@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class TechnicalJobOrder extends JobOrder{
}
@Entity
public class Occupation implements Serializable{
@OneToMany(mappedBy="occupation")
List<TechnicalJobOrder> jobOrders;
...
}
The problem that I am having is that in the class Occupation, hibernate tries to map the OneToMany relationship to TechnicalJobOrder.occupation - which does not exist, and consequently creates a field in the database that is always null. I would like to be able to map this relationship to the super class JobOrder.occupation but still retrieve a TechnicalJobOrder when I iterate through the list. For right now, I have changed JobOrder to be a @MappedSuperclass and this fixes my problem, however it is not the ideal solution for me as I would also like to be able to retrieve all the JobOrders in the system at once. Is there a simple way to do what I am trying to accomplish?
|