[英]Persisting a Map in JPA
I have the following classes 我有以下课程
class Category {
Long id;
}
class Question {
Long id;
@OneToOne (cascade=CascadeType.ALL)
Category category;
}
class Test {
Long id;
Map<Category, Long> splitUp;
}
These are partial versions of the my classes, I have annotated the category and Quesiton classes but having trouble annotating the map "splitUp" in the Test Class. 这些是我的类的部分版本,我已经注释了类别和Quesiton类,但是在测试类中注释了地图“ splitUp”时遇到了麻烦。 I would like some help in that.
我希望对此有所帮助。
class Test {
Long id;
@ElementCollection
@JoinTable(name = "CATEGORY_JOIN_TABLE", joinColumns = @JoinColumn(name = "category_join_table_id_column"))
@MapKeyJoinColumn (name = "category_id")
@Column(name = "id")
Map<Category, Long> splitUp;
}
This should work. 这应该工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.