We're updating the issue view to help you get more done. 

Entity with null many-to-one cannot be loaded when associated entity has composite ID with hibernate.create_empty_composites.enabled=true

Description

This bug is only relevant with hibernate.create_empty_composites.enabled=true.

To illustrate, suppose an entity has an optional many-to-one association with an entity that has a composite ID. After persisting an entity with a null many-to-one association, it will not be possible to load that entity using Session#get or Session#find.

Session#get or Session#find incorrectly returns null because Hibernate resolves the associated (hydrated) null ID as an empty composite, then attempts to load the associated entity, which fails because there is no entity with null values for its composite ID.

Hibernate logs a message like:
12:54:19,484 INFO DefaultLoadEventListener:129 - HHH000327: Error performing load command : org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.hibernate.test.component.empty.EmptyCompositeManyToOneTest$OtherEntity#OtherEntity{firstName='null', lastName='null', description='null'}]

Environment

None

Status

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

5.2.10
5.1.9

Priority

Major