Caused by: org.apache.openjpa.persistence.InvalidStateException: Attempt to set column "system_user.id" to two different values: (class java.lang.Integer)"6", (class java.lang.Long)"3,651" This can occur when you fail to set both sides of a two-sided relation between objects, or when you map different fields to the same column, but you do not keep the values of these fields in synch.
at org.apache.openjpa.jdbc.sql.PrimaryRow.setObject(PrimaryRow.java:344) ~[openjpa-2.4.0-nonfinal-1598334.jar:2.4.0-nonfinal-1598334]
at org.apache.openjpa.jdbc.sql.RowImpl.flushJoinValues(RowImpl.java:294) ~[openjpa-2.4.0-nonfinal-1598334.jar:2.4.0-nonfinal-1598334]
at org.apache.openjpa.jdbc.sql.RowImpl.flushPrimaryKey(RowImpl.java:186) ~[openjpa-2.4.0-nonfinal-1598334.jar:2.4.0-nonfinal-1598334]
at org.apache.openjpa.jdbc.sql.RowImpl.setPrimaryKey(RowImpl.java:167) ~[openjpa-2.4.0-nonfinal-1598334.jar:2.4.0-nonfinal-1598334]
public class YoungUser extends DatedModel {
.
.
.
@JoinColumn(referencedColumnName = "id", name = "system_user_id")
@OneToOne(cascade = CascadeType.ALL)
@Column(nullable = false)
public SystemUser getSystemUser() {
return systemUser;
}
.
.
.
}
It was working fine with constraints, but at some point it stopped behaving correctly.
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
protected int id;
previously it was assigned for getter.