Reference: https://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/DerivedIdentifiers https://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#d0e1112 When using an @IdClass that references another entity (in a One|ManyToOne relationship), the @IdClass should use the type of the primary key of the referenced entity. This is a completely supported scenario in Hibernate and any JPA compliant provider. However, when you enable Envers for the entity (i.e. make it @Audited), exceptions start to occur as Envers expects the types of the @IdClass to match the same fields in the entity. I have created a test case and an associated fix in the referenced pull request. |