我无法找到我的注释有什么问题(我使用过官方的hibernate文档)
public class DashletContainer{
private Map<UUID, DashletData> dashletData = new HashMap<>();
//STUFF
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "rd_container_data")
@MapKeyColumn(name = "dashletdata_dashlet_id")
public Map<UUID, DashletData> getDashletData() {
return dashletData;
}
}
public class DashletData{
//STUFF
@Column(name = "dashlet_id")
public UUID getDashletId() {
return dashletId;
}
@ManyToOne(cascade = CascadeType.ALL)
public DashletContainer getDashletContainer() {
return dashletContainer;
}
}
这是我在数据库上的连接表(rd_container_data)的结构:
dashletdata_id | UUID
dashletcontainer_id | UUID
dashletdata_dashlet_id | UUID
问题是当我持久化容器对象时,它内部的Map保持为Null并且没有任何内容插入到相应的表中。
谢谢
答案 0 :(得分:2)
@dave尝试在@MapKeyColumn(name = "dashletdata_dashlet_id")
上添加dashletData
,而不是getter