【发布时间】:2019-06-12 21:22:32
【问题描述】:
有两个实体Instrument 和Definition。
当instrumentCode 更改时,Envers 仅为Instrument 创建审核记录。
我希望当 instrumentCode 更改时 Envers 为 Instrument 和 Definition 实体创建审计记录。怎么可能做,有可能吗?
我玩过@AuditedJoinTable、@AuditedMappedBy 但没有运气。
@Audited
@Getter
@Entity
public class Instrument {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@Column(name = "instrument_code")
protected String instrumentCode;
@ManyToOne(optional = false, fetch = FetchType.LAZY, targetEntity = Definition.class)
@JoinColumn(name = "definition_id", nullable = false)
private Definition definition;
}
//-----
@Audited
@Getter
@Entity
public class Definition {
@Id
@Column(nullable = false)
protected String id;
@OneToMany(mappedBy = "definition",
orphanRemoval = true,
cascade = CascadeType.ALL,
targetEntity = Instrument.class)
private Set<Instrument> instruments = Sets.newHashSet();
}
【问题讨论】:
标签: java hibernate hibernate-envers