Created attachment 1075834 [details] hibernate4.01491237.HHH-5764.tar.gz When the composite primary key references more than 2 levels, it fails with the error "org.hibernate.AssertionFailure: Unexpected nested component on the referenced entity when mapping a @MapsId: xxx". For example: @Entity @IdClass(Level1EntityPK.class) public class Level1Entity { @Id @ManyToOne private Level2Entity level2Entity; ... } @Entity @IdClass(Level2EntityPK.class) public class Level2Entity { @Id @ManyToOne private Level3Entity level3Entity; ... } @Entity @IdClass(Level3EntityPK.class) public class Level3Entity { @Id @Column(name = "LEVEL3_ENTITY_NO") private String level3EntityNo; ... } A jira https://hibernate.atlassian.net/browse/HHH-5764 has already been raised.
I have attached a simple test project that could reproduce the issue. To run the test project: 1) edit the src/test/resources/META-INF/persistence.xml to use your own database connection properties(url, username, password, etc.) 2) type mvn clean package
Final touches are being made to upstream pull request. This should make it into EAP 6.4.6 if approved.
Verified with EAP 6.4.6.CR2
Retroactively bulk-closing issues from released EAP 6.4 cumulative patches.