Andrey Sarul
Andrey Sarul

Reputation: 1593

Hibernate envers: combined annotations @Audited and @AttributeOverride not working

I'm trying to come up with an audited entity by means of Hibernate envers feature. I have a base class: Result

@Entity
@Table(name = "result")
public class Result {

    @EmbeddedId
    @AttributeOverride(name = "value", column = @Column(name = "id"))
    private ResultId id;

    @Audited
    @Column
    private String value;

    @Audited
    @AttributeOverride(name = "value", column = @Column(name = "updated_by"))
    private PersonId updatedBy;

}

In application I make changes for the entity value and updated_by fields. But in audit table I see only changes for value property, but updated_by always has NULL. It seems to me that @Audited and @AttributeOverride is not compatible.

How can I achieve auditing for updated_by field?

Upvotes: 0

Views: 999

Answers (1)

Rohit
Rohit

Reputation: 2152

You need to use @AuditOverride rather than the @Audited, as you are overriding the default audit behaviour of the field.

Upvotes: 1

Related Questions