Hibernate本身会生成外键,但是我必须在我的实体对象中有一个声明的外键字段。例如:
@Basic(optional = false)
@Column(name = "CUSTOMER_ID", nullable = false)
private Integer customerId;
@OneToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(foreignKey = @ForeignKey(name = "CUSTOMER_ID"), referencedColumnName = "ID", nullable = false, name = "CUSTOMER_ID")
private CustomerEntity customer;
但这会生成:
实体映射中的重复列: AccountEntity列:CUSTOMER_ID(应为 映射为insert =“ false” update =“ false”)
但是如果我将customerId设置为
insert =“ false” update =“ false”
它尝试插入NULL值。
我该怎么做?