问题描述
我认为hibernate-envers及其使用的修订号存在问题。当我创建多个实体时,它们将被添加到审核表中,但是修订号不是我期望的。
我有一个全局修订序列,而不是每个实体的序列。即如果我更新实体,它不会获得grant_type=authorization_code&code=....
的修订版本号,而是会获得下一个免费的全局修订版本号。
示例:
old_entity.revision_number + 1
我的印象是修订版本编号将基于实体而不是全局,并且示例代码也暗示了这种行为。我的实体如下:
Entity a = new Entity(); // lets say id = 1
Entity b = new Entity(); // lets say id = 2
save(a);
save(b);
// modify a
save(a);
Entity aRevision1 = auditReader.find(Entity.class,1,1); // will be a (revisioned)
Entity bRevision1 = auditReader.find(Entity.class,2,1); // will be null
Entity bRevision2 = auditReader.find(Entity.class,2); // will be b (current)
Entity aRevision2 = auditReader.find(Entity.class,2); // will be null
Entity aRevision3 = auditReader.find(Entity.class,3); // will be a (current)
@Audited
@MappedSuperclass
public class BaseEntity {
@Id
@GeneratedValue
private Long id;
private String comment;
private String user_account;
private LocalDateTime touchDate;
@Basic (fetch = FetchType.LAZY)
private byte[] sourceData;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)