[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3026) Impossible cyclic requirement causes misleading error
Dobes Vandermeer (JIRA)
noreply at atlassian.com
Fri Dec 21 21:32:05 EST 2007
Impossible cyclic requirement causes misleading error
-----------------------------------------------------
Key: HHH-3026
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3026
Project: Hibernate3
Issue Type: Improvement
Affects Versions: 3.2.5
Reporter: Dobes Vandermeer
When you create an impossible cycle, for example:
class A {
@OneToMany(inverse="a")
List<A> listOfA = new ArrayList<A>();
@OneToOne(optional=false)
B specialB;
}
class B {
@ManyToOne(optional=false)
A a;
}
It's actually impossible for hibernate to insert the B referenced by 'specialB', because in order to insert it, A must have a valid primary key. In order to insert A, b must have a primary key.
This is fine, and I accept that hibernate does not work around this problem. However, the error message hibernate provides isn't just useless, it's actually misleading:
"not-null property references a null or transient value"
This message sent me on a useless multi-hour quest looking for a null or transient value, of which there were none.
If possible, hibernate should detect and report this as cyclic dependency when it flushes, and print a nicer error like:
"Instance of A requires B to have been inserted, but B also requires A to have been inserted; please make one of these properties nullable"
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list