通过多个映射为实体映射的重复列

时间:2018-11-01 14:00:01

标签: java hibernate jpa many-to-one embeddable

我不明白为什么我仍然收到 hibernate.MappingException

SCNMatrix4

PanelCategoryOption映射

aDecoder.decodeFloat(forKey: "someKey")

PanelCategoryOptionId映射

Repeated column in mapping for entity: PanelCategoryOption column: category_id (should be mapped with insert="false" update="false")

架构

enter image description here

1 个答案:

答案 0 :(得分:1)

为什么在PanelCategoryOption表中有category_id参考。 这不是规范化的数据库设计,因为它不满足“第二范式”形式。尝试更新您的数据库设计。

此外,如果您不想更改数据库设计,则需要进行以下更改,

  @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({
            @JoinColumn(name = "category_option_id", referencedColumnName = "id", insertable = false, updatable = false) })
    private CategoryOption categoryOption;

 @JoinColumns({
                @JoinColumn(name = "category_id", referencedColumnName = "category_id", insertable = false, updatable = false)})
 private Category category;