Have two entities Instrument
and Definition
.
When instrumentCode
changed Envers create audited record only for Instrument
.
I want that when instrumentCode
changed Envers create audited records for both Instrument
and Definition
entities. How it is possible to do, and is it possible?
I've played with @AuditedJoinTable, @AuditedMappedBy but without luck.
@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();
}