Audit table creation fails for ElementCollection Map with CLOB/NCLOB element column

Description

If an audited entity contains an @ElementCollection map, where the map value needs to store a large binary or text object, Envers fails to create the corresponding audit table.

For example, this will occur if the entity contains:

The issue occurs because Envers attempts to use the map property value as part of the audit table primary key. For example, based on the above ElementCollection, Envers will attempt to create a table as follows:

This fails (in H2 and MySQL which I tested) because a CLOB column is not permitted as part of a primary key.

This issue can be worked around by manually creating the audit table with a modified structure, using the REVTYPE column in place of the map value in the primary key. As far as I can tell, this workaround allows correct audit records to be generated for all types of revisions. Therefore, it seems the issue could be addressed by having Envers use this alternate structure by default rather than the current key containing the map value.

Environment

None

Status

Assignee

Chris Cranford

Reporter

Jon Kranes

Fix versions

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure