@Entity public class TestClass implements Serializable{ private Integer id; private Set<String> mySet; @Id @GeneratedValue public Integer getId() { return id; } @OneToMany(cascade={CascadeType.ALL}) public Set<String> getMySet() { return mySet; } }
我收到以下错误.
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: TestClass.mySet[java.lang.String]
或者如果我离开@OneToMany
org.hibernate.MappingException:无法确定:java.util.Set的类型,在表:test_class,对于列:[org.hibernate.mapping.Column(my_sets)]
解决方法
你会找到一个相当不错的答案
here.列表的规则也适用于集合.