无法找到逻辑名为hibernate的列

时间:2016-08-28 14:33:45

标签: java hibernate spring-boot h2

我有表,其中2列加入另一个关系。我尝试加入@JoinColumns,但收到错误Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to find column with logical name CLASS_ID in table item_sub_class 我查看了h2-console,在table_sub_class表中,我看到了列class_id。看截图 enter image description here

这是来自Item class

的关系代码
@Entity
@JsonIgnoreProperties(ignoreUnknown = true)
public class Item implements Serializable {
    @Id
    private Long id;
    private String description;
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "class_id")
    private ItemClass itemClass;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumns({
        @JoinColumn(name= "subclass_id",referencedColumnName = "subclass"),
    @JoinColumn(name= "class_id",referencedColumnName = "class_id")

    })
    private ItemSubClass itemSubClass;
    private Long sellPrice;
//getter and setters

}

和ItemSubClass

@Entity
public class ItemSubClass implements Serializable {
    @Id
    @GeneratedValue
    private Long id;
    @JsonProperty("subclass")
    @Column(name = "subclass")
    private Long subclass;
    private String name;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "class_id")
    private ItemClass itemClass;

//getters and setters



}

有人可以解释什么是坏的以及为什么这种关系会让我犯错误?这有可能解决这个问题吗?

0 个答案:

没有答案
相关问题