【发布时间】:2010-10-29 14:55:45
【问题描述】:
@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: Could not determine type for: java.util.Set, at table: test_class, for columns: [org.hibernate.mapping.Column(my_sets)]
【问题讨论】:
-
Hibernate 的 @CollectionOfElements 注释为我解决了这个问题。它是特定于休眠的,但我不打算换掉我的 JPA 实现。