I have an Entity called Student, and that entity can choose how he wants to schedule his study. So, that’s the use case for an interface, called StudySchedulingMethod, enabling many scheduling methods to exist.
The deal is, how does JPA map this? Can it do it? Is there another way?
Example code:
@Entity
public class Student {
@Id
@GeneratedValue
private Long id;
// How to map this?
private StudySchedulingMethod studySchedulingMethod;
}
public interface StudySchedulingMethod {
double getHoursToStudy();
}
I thought about creating a String field to store the name of the implementation that the Student would be using, but I think that’s very ugly and probably there is a better way.