【发布时间】:2016-10-15 14:07:18
【问题描述】:
我有实体医生
@Entity
public class Doctor extends Account {
//other attributes
@Column
@ElementCollection(targetClass = Speciality.class, fetch = FetchType.EAGER)
private Set<Speciality> speciality = new HashSet<Speciality>(0);
//getters and setters
}
和实体专长
@Entity
public class Speciality {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
String name;
//getters and setters here
}
现在在我的应用程序中,用户可以选择想要访问的医生的专业。例如用户选择 内分泌学家,现在我的应用程序需要找到所有在 Set 专业中拥有专业内分泌学家的医生。 如何做到这一点?
【问题讨论】:
-
嘿@implssv。请给我反馈我的answer。如果它对您有用,请将其标记为已接受。
-
每个答案都很好,但你写了更多关于良好实践的内容:)