【发布时间】:2020-06-05 22:37:59
【问题描述】:
我有两个集合,默认情况下由休眠设置为 PersistentSet。问题是在引擎盖下休眠将它们转换为 HashSet,但我希望将它们设置为 LinkedHashSet,因为我想保留添加元素的顺序。
@ElementCollection(fetch = FetchType.LAZY)
private Set<String> responsibilities;
@ElementCollection(fetch = FetchType.LAZY)
private Set<String> requirements;
我尝试了几件事,但没有成功
public void setResponsibilities(LinkedHashSet<String> responsibilities) {
this.responsibilities = responsibilities;
}
public void setRequirements(LinkedHashSet<String> requirements) {
this.requirements = requirements;
}
我尝试的另一件事是:
@ElementCollection(fetch = FetchType.LAZY)
private Set<String> requirements = new LinkedHashSet<>();
【问题讨论】:
-
你用的是什么休眠版本?
-
hibernate 5 spring boot 2+
标签: hibernate nhibernate-mapping linkedhashset persistent-set