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
you will get to
org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(...) line 117:
Serializable generatedId = persister.getIdentifierGenerator().generate( source, entity );
then org.hibernate.mapping.Component.ValueGenerationPlan.execute(...) line 440
will set generatedValue = IdentifierGeneratorHelper.POST_INSERT_INDICATOR
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
all (e.g. PostgreSQL 9.4)