且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

一对多映射到超类的属性

更新时间:2021-10-05 08:57:09

找到了解决方案... :)

Found the solution for this... :)

我们可以通过定义 targetEntity = 来实现这一点.在 OneToMany 定义中..

We can achieve this just by defining the targetEntity = ? in the OneToMany definition..

例如...

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "activity" , targetEntity=NQIQuestions.class)    
private Set<NQIMultipleChoiceQuestions> mcqQuestions = new HashSet<NQIMultipleChoiceQuestions>();