Envers - EntityExistsException for List of Embeddables without OrderColumn

Description

When trying to persist or merge an entity containing a list field of @Embeddable s and that field is not annotated with @OrderColumn (but, for example, with @OrderBy), the commit fails with the below exception:

When using a Set or adding an @OrderColumn, it works as expected. But since Hibernate Core works fine without these, shouldn't Envers as well?

I've created a more-or-less minimal test project to reproduce this issue: https://github.com/MHajoha/envers-list-bug-repro

It seems that the identifier generated by Envers for the audit entity doesn’t contain enough information and is equal between the different audiit events. (In my example, the composite ID only consists of REV, REVTYPE and MyEntity_id) When adding @OrderColumn, that column is added to the composite-id.

A solution that would work for us is to add the column referenced by the @OrderBy annotation to the composite-id. Perhaps it may also be possible to allow the user to specify additional properties to be added?

Another solution, sorta proposed in , might be to add all non-null properties of the component.

This StackOverflow question also seems to be caused by the same issue.

Activity

Show:

Details

Assignee

Reporter

Components

Affects versions

Priority

Created July 5, 2021 at 1:56 PM
Updated July 6, 2021 at 11:02 AM