我与两类loan和loanguarantors有一个标题详细信息关系,loan类如下所示:
@Entity
@Table(name = "LOAN")
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Loan extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "USER_ID", updatable = false, nullable = false)
private User user;
@Column(name = "AMOUNT", nullable = false)
private Double amount;
@Enumerated
@Column(name = "LOAN_TYPE", columnDefinition = "smallint", nullable = false)
private LoanType loanType;
@Enumerated
@Column(name = "LOAN_STATUS", columnDefinition = "smallint", nullable = false)
private LoanStatus loanStatus;
}
loanguarantor类的定义如下:
@Entity
@Table(name = "LOAN_GUARANTORS")
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class LoanGuarantors extends BaseEntity {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "GUARANTOR_ID", updatable = false, nullable = false)
private User guarantor;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "LOAN_ID", updatable = false, nullable = false)
private Loan loan;
@Column(name = "GUARANTE_AMOUNT", nullable = false)
private Double guaranteAmount;
}
当loanstatus在loan表中提交更改时,我想在audit表中保留具有相同版本的记录(包括loan、loanguarantor)的历史记录(假设每个记录都有一个audit表,例如,loan\u audit和loan\u guarantor\u audit)。这个问题有什么合适的解决办法?我在考虑hibernate envers或其他cdc解决方案,比如debezium,但问题是当loan表中发生更改时,它们只跟踪loan表,而不跟踪它们之间的关系。
暂无答案!
目前还没有任何答案,快来回答吧!