I have this piece of code:
@Entity
@Table(name = "MOVERS")
public class MOVers implements Serializable {
@OneToOne(fetch = FetchType.LAZY)
@JoinColumns({
@JoinColumn(name = "X1077_69_EDECESSOR", referencedColumnName = "CLASSID"),
@JoinColumn(name = "X1077_70_EDECESSOR", referencedColumnName = "ID")})
private MOVers predecessor;
}
The database should not have null values. If created version is the first then it should not have predecessor, and columns (X1077_69_EDECESSOR, X1077_70_EDECESSOR) should be equal to 0. I thought about creation of Dummy object for this reason, but it is not possible because some other columns must be unique.
How can I do it by using EclipseLink?
The database have no any foreign keys, and this DB is used in other application with persistence API that do not understand NULL fields. I solved this problem when I have added UPDATE statement, like this one, to the creation stage of the new object:
SET X1077_69_EDECESSOR = 0, X1077_70_EDECESSOR = 0, WHERE ID = :moversid
In this case new object creates with NULL fields and then they will be updated to 0 value.