Turn from:insertable = false, updatable = False use
When using JPA to configure an entity, if there are two attributes (one is a generic attribute and one is a many-to-one property), the error will be indicated when mapping to the same column in the database.
At this point, add insertable = False, updatable = False, in the @joincolumn annotation of the many-to-one to resolve.
For example:
/*** User Class*/@Entity @Table (name= "Tbl_sys_user") Public classsysuser{@Id @GeneratedValue (Generator= "System-uuid") @GenericGenerator (name= "System-uuid", strategy = "UUID") @Column (name= "user_id", unique =true, length = 40) @CsvColumn (imported=false) PrivateString ID;//User ID@Column (Name= "User_code", nullable =false, length = 40) PrivateString Usercode;//User Account@CsvColumn (desc= "User name", required=true) @Column (name= "user_name", length = 60) PrivateString UserName;//User name@Column (Name= "dept_id", length = 40) PrivateString DeptID;//Department ID (is_org=0)@ManyToOne @JoinColumn (name= "dept_id", insertable =false, updatable =false, nullable=true) Privatesysorg Dept;//Department Object }
As we can see, DeptID and Dept all map to the dept_id field inside the database, but with insertable = false, updatable = False, Dept will not be saved to the database when the data is saved.
Insertable = False, use of updatable = False