使用JPA进行数据操作,在ManyToOne 和OneToMany中,很容易遇到如下问题。
遇到的问题:Multiple writable mappings exist for the field [{0}]. Only one may be defined as writable, all others must be specified read-only.
解决方案是:在 @JoinColumn中加入updatable=false,insertable=false
@ManyToOne(optional=false)
@JoinColumn(name="RECORD_ID",nullable=false, updatable=false,insertable=false)
private Record record;