Am trying to get the revision number using the findLastChangeRevision method in spring-data-envers. Am able to fetch the last entity but the revision is alwaysUNKNOWN. And the revision number and timestamp are empty and null respectively always.
Tried debugging with getting all revisions found that all the revisions are UNKNOWN and their revision number and timestamp are same as empty and null respectively.
Below is my AuditRevisionListener have the field annotated with @RevisionNumber and @RevisionTimeStamp
@RevisionEntity(AuditRevisionListener.class)
public class AuditRevisionEntity {
@Id
@GeneratedValue(generator = "revision_info_id_generator")
@GenericGenerator(
name = "revision_info_id_generator",
strategy = "org.hibernate.id.enhanced.SequenceStyleGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "revision_info_id_seq"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1")
})
@RevisionNumber
private Long revisionId;
@RevisionTimestamp
private long timestamp;
@Column(name = "user_id")
private Integer userId;
}
The version of spring-boot is 2.6.2
Referred this already and is a bit different to the above context. Could this be a bug?
spring-data-envers revisionType UNKNOWN
I understand the solution can be obtained using hibernate-envers, but looking into using tspring-data-envers
Thanks
Hibernate may proxify your
AuditRevisionEntitywhen Spring-Data in its turn will try to use reflection to get the values of revision id and a timestamp. The problem is that the proxy object hides this values until you use getter method. Adding@Proxy(lazy = false)annotation on your revision entity might help.See this issue for reference: https://github.com/spring-projects/spring-data-envers/issues/250