| Summary: | Null reference inserted for self-referencing entity instance | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Adrian Gygax <adrian.gygax> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | NEW --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
Adrian Gygax
Please post, at least, a description of the problem in the bug. Problem description:
I have the following:
@Entity
public class User {
@Id
@GeneratedValue(strategy = SEQUENCE)
@Column(name = "id", nullable = false, updatable = false)
private Long id = null;
@OneToOne
@JoinColumn(name = "created_by", updatable = false, nullable = false)
private User createdBy;
...
}
Then I persist it
User u = new User();
u.setCreatedBy(u);
em.persist(u);
As you see the user creator is himself.
I get the error of:
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column
"created_by" violates not-null constraint
EclipseLink generates an SQL statement with CREATED_BY = NULL. This happens even if I manually set an ID for the User.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |