We would like to keep trace of who change something into our database.
We have already activate Envers auditing to keep track of the different version of our record.
However when I do the log I would like to specify the revision of the entity when it was changed. I have added an EventListeners on the Entity that will call the logger after any change on the entity but can't find a way to get the version.
I have tried to use the @Version annotation but this one has different value than the REV column in the audit table.
Here is some part of the code:
@Entity(name = "Rules")
@EntityListeners(AuditListener.class)
@Audited(withModifiedFlag = true)
public class Rule {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "Id")
private Integer id;
@XmlTransient
public Integer getId() {
return id;
}
public void setId(Integer id) {
}
private String gufid;
@NotNull
@Column(name = "Code", nullable = false, columnDefinition = "NVARCHAR(55)")
private String code;
@NotNull
@Lob
@Column(name = "Expression", nullable = false, columnDefinition = "NVARCHAR(MAX)")
private String expression;
@NotNull
@Column(name = "RuleType", nullable = false, columnDefinition = "VARCHAR(20)")
@Enumerated(EnumType.STRING)
private RuleType ruleType;
@Column(name = "Description", columnDefinition = "NVARCHAR(255)")
private String description;
@Version
private Long version;