The fix for HHH-12436 involves correcting the foreign key direction for
some one-to-one assocations. In the process of making changes I see that we
have a unit test that has a unidirectional one-to-one association mapped
with constrained="false". [1]

ModelBinder assumes that <one-to-one ... constrained = "true"> means that
the foreign key direction is FROM_PARENT; if constrained = "false", it
assumes that the foreign key direction is TO_PARENT. [2]

It seems odd to me that the foreign key direction for a unidirectional
association would be TO_PARENT.

Should the unit test have constrained = "true"?

If not, should ModelBinder check to see if the association is bidirectional
and determine which side owns the association? This would probably require
adding a SecondPass.

Please let me know your thoughts.

Regards,
Gail

[1]
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/test/java/org/hibernate/test/onetoone/optional/Person.hbm.xml
[2]
https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java#L2114-L2131
_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to