ManyToOne/OneToOne with non-identifier JoinColumn referenced column name does not audit relation.

Description

When auditing a foreign key, Envers seems to be ignoring the JoinColumn annotation.

E.g. I have a simple class like this:

Which references a lookup table like this:

Notice that the addressType attribute on Address is joining to the entityId column, not the primary key "id" column. Also notice the use of RelationTargetAuditMode.NOT_AUDITED : I want to audit the foreign key, but I don't want to Audit changes to AddressTypeLookup. The problem is, when Envers records changes to the foreign key, it's recording the AddressTypeLookup primary key value "id", not the entityId. How do I make Envers record the entityId values used?

[In case you're wondering why I want this: we have a database of lookup data (aka master / reference data). It records history: all rows have effective from/to dates. The id column is properly unique; the entityId identifies a particular thing - e.g. all versions of a particular address type. All the lookup tables are replicated into an application database - but only the current data is replicated, not the historic data. ]

Environment

None

Assignee

Chris Cranford

Reporter

tim kane

Fix versions

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure