IllegalArgumentException when composite ID has IDENTITY generated value

Description

When composite ID has at least one IDENTITY generated value, you cannot persist an entity.

Suppose you have a class (getters-setters and other stuff is cut to be shorter):

When you try to persist in debug

  1. you will get to
    org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(...) line 117:
    Serializable generatedId = persister.getIdentifierGenerator().generate( source, entity );

  2. then org.hibernate.mapping.Component.ValueGenerationPlan.execute(...) line 440
    will set generatedValue = IdentifierGeneratorHelper.POST_INSERT_INDICATOR

  3. later org.hibernate.property.BasicPropertyAccessor.BasicSetter.set(...) line 68 will try to set IdentifierGeneratorHelper.POST_INSERT_INDICATOR (String) to Long and this will cause an exception, which will bubble up, but not handled appropriately, so the code will never return to org.hibernate.event.internal.AbstractSaveEventListener line 124 for comparing generated ID with IdentifierGeneratorHelper.POST_INSERT_INDICATOR

This is not happening when ID is non-composite.

Also I have reported somewhat related bug #HHH-9657 . In general looks like Hibernate is a bit weak with composite IDENTITY IDs

Environment

all (e.g. PostgreSQL 9.4)

Attachments

Assignee

Fabio Massimo Ercoli

Reporter

Ivan Bondarenko

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure