Java – how to map a set of string objects using JPA annotations?
•
Java
@Entity
@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;
}
}
I received the following error
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: TestClass.mySet[java.lang.String]
Or if I leave @ onetomany
org. hibernate. Mappingexception: unable to determine: Java util. Type of set in table: Test_ Class, for column: [org. Hibernate. Mapping. Column (my_sets)]
Solution
You'll find a pretty good answer here The rules for lists also apply to collections
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
