Persisting partially-generated composite Ids fails with HibernateException: No part of a composite identifier may be null

Description

Suppose we have following entities:

Persisting these fails with:

Activity

Show:
V. Dubus
December 5, 2018, 11:02 AM
Edited

This bug still exist in version 5.2.17.

I have the same error with HSQLDB when running my tests.
The ID is generated using a SEQUENCE.

V. Dubus
December 6, 2018, 10:50 AM

Quick sample project to show case the bug with a composite key and a part of it should be generated.

Was test using the latest version of Hibernate 5.4.0.CR2.
Changing the @GeneratedValue from SEQUENCE to IDENDITY still make the same error.

IT Support
April 22, 2020, 6:26 PM

Tracked this down, it was caused by HHH-4848 on Wed Feb 3 06:58:46 2010 +0000
see:

The check used to skip null values with a continue, but was changed to throw an exception. As such HHH-10956 is a regression caused by HHH-4848

This is the (relevant) commit log for the offending file

commit 3906816ee2625987796feb587ca374a55c3374ae
Author: Steve Ebersole steve@hibernate.org
Date: Mon Dec 19 16:35:48 2016 -0600

HHH-11274 - EntityManagerFactoryImpl.getIdentifier uses deprecated version of getIdentifier

 

commit 87e3f0fd28d7229b0a35032292ff32f542c22010
Author: Steve Ebersole steve@hibernate.org
Date: Tue Apr 19 13:14:02 2016 -0500

HHH-10664 - Prep 6.0 feature branch - merge hibernate-entitymanager into hibernate-core (first sucessful full compile of consolidated hibernate-core)

 

commit 611f8a0e1c3764dc4505a32294ff0fbeaa8d2e6b
Author: Steve Ebersole steve@hibernate.org
Date: Mon May 18 13:35:26 2015 -0500

HHH-9803 - Checkstyle fix ups

 

commit 8fe5460ec03942e974d4aae7d9060e20bab7f990
Author: Steve Ebersole steve@hibernate.org
Date: Sun Nov 24 20:07:37 2013 -0600

HHH-8741 - More checkstyle cleanups

 

commit 19791a6c7d17f6f5d74dd9b42bdb4fcb7f5a9be1
Author: Steve Ebersole steve@hibernate.org
Date: Fri Mar 18 15:51:43 2011 -0500

HHH-6026 - Migrate bytecode provider integrations to api/spi/internal split

 

commit 839e23458aa0c50e1dc0d8f1a1bed87dbff49f3b
Author: Steve Ebersole steve@hibernate.org
Date: Mon Feb 8 19:27:00 2010 +0000

HHH-4704 - Pass session into EntityTuplizer#setIdentifier

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18733 1b8cb986-b30d-0410-93ca-fae66ebed9b2

 

commit 53b1890c1b2b43a8dc89f0f09d6d3b6b6f3cbdc1
Author: Steve Ebersole steve@hibernate.org
Date: Fri Feb 5 02:42:55 2010 +0000

HHH-4848 - Derived identities: Derived entities using @IdClass and mapping a @XToOne are not supported

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18698 1b8cb986-b30d-0410-93ca-fae66ebed9b2

 

IT Support
April 22, 2020, 11:29 PM

pull request

IT Support
April 23, 2020, 2:17 AM

back-ported 5.2.x pull request

Assignee

Unassigned

Reporter

Mark Paluch

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure