|
Hi. After upgrading from Hibernate 4.1.3 to 4.3.9 we are getting some weird nullability issues with bidirectional one-to-many associations in a component. For a working test case see attached ZIP.
The problem seems to be introduced between 4.1.10.Final and 4.1.11.Final -> works with 4.1.10.Final and below but doesn't work as of 4.1.11.Final or above.
Explanation: Parent has a bidirectional one-to-many to Child and Child has a second many-to-one to Parent. The bidirectional one-to-many is managed from the Parent side, the Child side is the inverse side. The unidirectional association to Parent is managed by Child.
Parent:
<bag name="children" cascade="all-delete-orphan">
<key column="parent_id" not-null="true" update="false" />
<one-to-many entity-name="Child" />
</bag>
Child:
<component class="be.SomeComponent" name="component">
<many-to-one name="parent" column="parent_id" not-null="true" insert="false" update="false" lazy="false"/>
<many-to-one name="nextParent" column="next_parent_id" not-null="true" update="false" lazy="false"/>
</component>
When running the test case:
At this stage no queries have been flushed to the database. When the component is removed and the associations mapped directly in Child:
<many-to-one name="parent" column="parent_id" not-null="true" insert="false" update="false" lazy="false"/>
<many-to-one name="nextParent" column="next_parent_id" not-null="true" update="false" lazy="false"/>
The test case works without any problem.
|