Loading parent/child entities with foreign key in child table being its primary key
results in StackOverflowError
-----------------------------------------------------------------------------------------------------------------
Key: HHH-6708
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6708
Project: Hibernate Core
Issue Type: Bug
Components: core
Affects Versions: 3.6.6
Environment: HSQL 1.8.0.10 (also reproducible with Oracle 11g, with Oracle JDBC
11.2.0.1.0
Reporter: Florian Rampp
Attachments: bugreports-hibernate-cascadeAll-1.0-SNAPSHOT-src.zip
Consider the following parent/child relationship mapping:
{code:java}
@Entity
public class Parent {
@Id
Long id;
// @OneToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE,
CascadeType.REFRESH,
// CascadeType.DETACH }, orphanRemoval = true, mappedBy = "parent")
@OneToOne(cascade = CascadeType.ALL, orphanRemoval = true, mappedBy =
"parent")
Child child;
void setChild(Child child) {
this.child = child;
child.setParent(this);
}
}
@Entity
public class Child implements Serializable {
@Id
@OneToOne(optional = false)
private Parent parent;
public void setParent(Parent parent) {
this.parent = parent;
}
}
{code}
When storing a parent with a child and loading it again, the load results in a
StackOverflowError. When I replace the cascade type {{ALL}} with a list of all cascade
types {{\{CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE, CascadeType.REFRESH,
CascadeType.DETACH\}}}, the error does not occur any more.
I attached a test case.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira