On doing a saveOrUpdate of an object whose class participates in a one-to-one mapping, Hibernate is attempting to store a garbage value into a foreign key field (of type Integer) in the corresponding table row. Sometimes the value is a huge integer--other times, it is some weird poison value that even breaks SQL*Plus when I try to view it. The result is an Oracle 2291 error (integrity constraint violated, parent key not found). From looking at the Hibernate debug log, the value seems to be reported to be correct (zero) prior to the insert.
I've stripped out Spring, DbUnit, and various other things to try to get a simple test case. (I'm still using JUnit.) There are 5 classes, 375 lines of Java. This is still too big to post here, but the complete project is at
http://www.lexonics.com/hibernateProblem.tar.gz. Download, unzip, and untar, and type "maven" to run.
The Hibernate version is 2.1.4. The mapping documents are included in the download. The Java code is in the file ZotTest.java. The stack trace is in the debug level log file hibernate.log. The database is Oracle, probably some 8.x version.
If I comment out the setPublishDate call, the test appears to run successfully, but another column (VERSION) has a garbage value.
I would appreciate any help you can give me. The xdoclet tags for the one-to-one mapping are set up correctly (as far as I know!).
Thank you.