| Summary: | Integrity constraint violation - no parent ... | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | MK Maddy <rkumaresh> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | major | ||
| Priority: | P2 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 7 | ||
| Whiteboard: | |||
|
Description
MK Maddy
Test case is incorrect. This mapping should reference ClassA instead of Long. Long cannot be the target of a 1-1 @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="INTERNALOTHERID") private Long internalOtherId; (In reply to comment #1) > Test case is incorrect. This mapping should reference ClassA instead of Long. > Long cannot be the target of a 1-1 > > @OneToOne(fetch=FetchType.LAZY) > @JoinColumn(name="INTERNALOTHERID") > private Long internalOtherId; Sorry that was my mistake proving the wrong mapping. But still its a valid issue with the correct mapping, please find it below. Table_A columns(ID, INTERNALOTHERID) ClassA @Id() private Long id; @OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="INTERNALOTHERID") private ClassA internalOtherId; Please post the code you use to create the objects, associate them and flush them. Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@Entity
@Table(name="ClassA")
public class ClassA {
@Id()
private Long id;
@JoinColumn(name="INTERNALOTHERID")
@OneToOne(fetch=FetchType.LAZY)
private ClassA internalOther;
public ClassA() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public ClassA getInternalOther() {
return this.internalOther;
}
public void setInternalOther(ClassA internalOther) {
this.internalOther = internalOther;
}
}
Test Case:
**********
public void testClassA() throws Exception {
ClassA one = new ClassA();
one.setId(Long.valueOf(100));
ClassA two = new ClassA();
two.setId(Long.valueOf(200));
two.setInternalOther(one);
one.setInternalOther(two);
getEntityManager().persist(one);
getEntityManager().persist(two);
getEntityManager().flush();
}
Working in version 2.2.0-M5 The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |