TransientObjectException thrown on dirty check during flush with CHECK_NULLABILITY set to false

Description

TransientObjectException thrown on dirty check of a many-to-one association during flush with CHECK_NULLABILITY set to false when the entity being dirty-checked:

  • has a "delayed-insert" ID generator (e.g., sequence, increment),

  • has been saved, but not flushed

This may also happen on an update.

I believe JDBCException should be thrown instead.

This is reproduced by testMergeEntityWithNonNullableTransientEntity() in:

  • MultiPathCircleCascadeTest for Oracle10gDialect and PostgreSQLDialect
    (because these dialects use sequences for the native ID generator and the default for CHECK_NULLABILITY is false)

  • MultiPathCircleCascadeCheckNullibilityFalseTest for Oracle10gDialect and PostgreSQLDialect
    (because these dialects use sequences for the native ID generator and CHECK_NULLABILITY is explicitly set to false)

  • MultiPathCircleCascadeDelayedInsertTest for all dialects
    (because the test uses an "increment" generator and the default for CHECK_NULLABILITY is false)

  • MultiPathCircleCascadeCheckNullFalseDelayedInsertTest
    (because the test uses an "increment" generator and CHECK_NULLABILITY is explicitly set to false)

The failure is masked in MultiPathCircleCascadeDelayedInsertTest and MultiPathCircleCascadeCheckNullFalseDelayedInsertTest because they incorrectly allow TransientObjectException as valid behavior.

Activity

Steve EbersoleFebruary 9, 2012 at 6:22 AM

Closing for 4.1 release

Former userJanuary 21, 2012 at 2:01 AM

Fixed by HHH-6957.

Former userJanuary 6, 2012 at 11:56 AM
Edited

After discussing this with Emmanuel, we agreed that it is appropriate for Hibernate to throw an exception if it is known that a non-nullable entity association is transient, rather than waiting for the insert to fail with JDBCException.

Emmanuel suggested that PropertyValueException might be a more appropriate exception than TransientObjectException in this case.

This issue will be fixed by https://hibernate.atlassian.net/browse/HHH-6957#icft=HHH-6957 as this case will be detected by the persist/save/merge operations, rather than during flush.

Former userOctober 19, 2011 at 2:06 AM

I've backed out of the change in the previous comment. Instead, testMergeEntityWithNonNullableTransientEntity() will be skipped if CHECK_NULLABILITY is false and the ID is a sequence or increment generator.

Former userOctober 19, 2011 at 12:30 AM

I've disabled MultiPathCircleCascadeCheckNullibilityFalseTest.testMergeEntityWithNonNullableTransientEntity() for Oracle10gDialect and PostgreSQLDialect.

Duplicate

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created October 19, 2011 at 12:13 AM
Updated February 9, 2012 at 6:22 AM
Resolved January 21, 2012 at 2:01 AM

Flag notifications