我正在使用休眠Envers审核我的实体。 我有这样的OfficeEntity:
@Entity
@Audited
@EntityListeners({AuditingEntityListener.class})
@Table(name = "office")
@AuditTable("office_aud")
public class OfficeEntity extends Auditable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "office_id")
private Long id;
@Column(name = "office_code")
private String officeCode;
@Column(name = "office_name")
private String OfficeName;
//getters & setters & constructor
}
和这样的可审核实体:
@MappedSuperclass
public class Auditable{
@CreatedBy
@Column(name = "created_by")
private String createdBy;
@CreatedDate
@Column(name = "created_date")
private Date createdDate;
@LastModifiedBy
@Column(name = "last_modified_by")
private String lastModifiedBy;
@LastModifiedDate
@Column(name = "last_modified_date")
private Date lastModifiedDate;
//getters & setters & constructor
}
使用此结构似乎审核字段未填写office_aud表。 所以谁知道我该如何在office_aud表中填写审核字段?
答案 0 :(得分:0)
我在休眠envers中发现了注释,它解决了这个问题。 因此,您可以添加:
@AuditOverride(forClass = Auditable.class)
子实体类,将设置审核字段。 子实体将如下所示:
@Entity
@Audited
@Table(name = "office")
@AuditOverride(forClass = Auditable.class)
@AuditTable("office_aud")
public class OfficeEntity extends Auditable{
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "office_id")
private Long id;
@Column(name = "office_code")
private String officeCode;
@Column(name = "office_name")
private String OfficeName;
//getters & setters & constructor
}