[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2128?page=c...
]
Patrick Moore commented on HHH-2128:
------------------------------------
I filed this because the code didn't detect this error and because this would result
in quiet data corruption. It is only by pure luck that I happened to discover this issue.
And .. no it is not 'obvious' that this would cause a problem. Hibernate seems to
be smart and in many cases it will quietly add a column if needed to manage a collection.
In this case I was fully expecting that it would add such a column to enforce the
relationship.
I would suggest that the one-to-one mapping result in an added column to enforce the 1-1
relationship. It is always possible to turn off this as default behavior by using the
property-ref attribute.
data corruption using one-to-one mapping
----------------------------------------
Key: HHH-2128
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-2128
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.0.cr4
Environment: hsqldb 1.8.0
Reporter: Patrick Moore
Priority: Blocker
Attachments: hibernatetests.zip
Please notice that this situation arose from the most minimal definition. Using the
'defaults' is what caused this issue!
See attached zip for definitions and reproduction test case.
Steps:
1. define two classes (Primary, Secondary) that have a one-to-one relationship.
2. save a primary with no assigned secondary object.
3. save another primary with a secondary object.
4. retrieve the first primary and it will have the secondary object saved in step 3.
5. retrieve the second primary and it will have no secondary object.
Suggested solution:
require that 'one-to-one' enforce an implicit non-null requirement between
primary and secondary.
--
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira