我对Envers(历史创造者)在Mediator Class中的应用有疑问。
问题是,当关系中的对象更改值时,如何在中介类中应用审计。
例如,在我的 ProjectMediator 课程中,我遇到了这种情况:
@Entity
@NamedQueries({
@NamedQuery(name = "ProjectMediator.findProjectMediatorByIdProject",
query = "SELECT pm FROM ProjectMediator pm WHERE pm.project.id = :idProject")
})
@Audited
public class ProjetMediator implements Serializable {
private static final long serialVersionUID = 1L;
public static final String FIND_PROJECT_BY_ID_PROJECTMEDIATOR = "ProjectMediator.findProjectMediatorByIdProject";
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@OneToOne
@JoinColumn(name="id_project")
private Project project;
@ManyToMany( targetEntity=Task.class, fetch=FetchType.LAZY )
private List<Task> tasks;
@ManyToMany( targetEntity=Activite.class, fetch=FetchType.LAZY )
private List<Acitvity> activities;
@ManyToMany( targetEntity=Phase.class, fetch=FetchType.LAZY )
private List<Phase> phases;
//get and sets }
而我需要在Phase对象改变值时创建一个history,所以history需要ProjectMediator的id、id Phase和data Phase。
任何人都知道如何创建类似的东西?
太感谢了!!