Audit table schema generation creates foreign key constraint to Entity table for EmbeddedId containing ManyToOne

Description

Consider the following minimal example:

Parent

CorrectChild

CorrectChildId

IncorrectChild

IncorrectChildId

Now, when generating the Envers schema using <property name="hibernate.hbm2ddl.auto" value="create"/>, the audit tables for Parent and CorrectChild are generated correctly. However, the audit table for IncorrectChild is then incorrectly containing a foreign key constraint to Parent.
I assume that Envers uses Hibernate mechanisms to generate DDL and does not cover the case that an @EmbeddedId can contain not only primitive fields but also references to other entities which have to be skipped like any other @OneToOne or @ManyToOne relationship.

Environment

None

Assignee

Chris Cranford

Reporter

Johannes Geiger

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure