Repeated column in mapping for entity

对实体类做映射时

@ManyToOne
@JoinColumn(name="customer_id")
private Customer customer;

@ManyToOne
@JoinColumn(name="customer_id", referencedColumnName = "customer_id")
private CustomerAuthentication customerAuthentication;

会报下面的异常信息,customer_id被重复使用

Repeated column in mapping for entity: xx.xx column: 
customer_id (should be mapped with insert="false" update="false")

改成下面的这种形式就可以了。

@ManyToOne
@JoinColumn(name="customer_id")
private Customer customer;

@ManyToOne
@JoinColumn(name="customer_id", referencedColumnName = "customer_id", insertable = false, updatable = false)
private CustomerAuthentication customerAuthentication;

猜你喜欢

转载自blog.csdn.net/sinat_33151213/article/details/79651393
今日推荐