Issues

Select view

Select search mode

 

Nullability issues when having many-to-one associations inside a component

Description

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:

org.hibernate.PropertyValueException: not-null property references a null or transient value : Child.component.parent at org.hibernate.engine.internal.Nullability.checkNullability(Nullability.java:117)

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.

Attachments

2
  • 18 Nov 2015, 11:56 AM
  • 07 May 2015, 07:42 AM

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Created May 7, 2015 at 7:44 AM
Updated November 18, 2015 at 5:16 PM

Activity

Koen SerneelsNovember 18, 2015 at 11:55 AM

Hi. This is still an issue with H5.0.3. I have bumped the libraries in the updated test case (see hibernate-nullability-H5.zip) nothing else changed. To summarize, when having a bi-directional one-to-many association, Hibernate complains when setting the inverse side (in this example the many side) to not-null. This problem only occurs when putting the relation it in a component. Without the component it works as expected, so this must be a bug.

Steve EbersoleOctober 28, 2015 at 3:25 AM

As part of verifying that this issue affects 5.0, please just set the "Affects version". Leave the "verify-affects-5.0" label and leave the issue in "Awaiting Response" status; these are critical for us to be able to track these verifications and triage them. Thanks.

Steve EbersoleOctober 27, 2015 at 7:17 PM

This bug report does not indicate that the reported issue affects version 5.x. Versions prior to 5.x are no longer maintained. It would be a great help to the Hibernate team and community for someone to verify that the reported issue still affects version 5.x. If so, please add the 5.x version that you verified with to the list of affected-versions and attach the (preferably SSCCE) test case you used to do the verification to the report; from there the issues will be looked at during our triage meetings.

For details, see http://in.relation.to/2015/10/27/great-jira-cleanup-2015/

Flag notifications