如何为许多实体配置EclipseLink历史记录策略?

时间:2016-04-18 11:53:13

标签: java jpa eclipselink history

我想使用EclipseLink历史记录策略来跟踪实体更改的历史记录,但我的项目中有超过50个实体。我是否必须为每个实体实现Customizer类,如下所示,或者我可以使用更通用的方法。

任何文件或建议都将不胜感激。

HumanResource_EmployeeCustomizer.java

public class HumanResource_EmployeeCustomizer implements DescriptorCustomizer {

    @Override
    public void customize(ClassDescriptor cd) throws Exception {
        HistoryPolicy policy = new HistoryPolicy();
        policy.addStartFieldName("START");
        policy.addEndFieldName("END");
        policy.addHistoryTableName("EMPLOYEE", "HUMANRESOURCE_EMPLOYEE_");
        cd.setHistoryPolicy(policy);
    }
}

HumanResource_JobDetailCustomizer.java

public class HumanResource_JobDetailCustomizer implements DescriptorCustomizer {

    @Override
    public void customize(ClassDescriptor cd) throws Exception {
        HistoryPolicy policy = new HistoryPolicy();
        policy.addStartFieldName("START");
        policy.addEndFieldName("END");
        policy.addHistoryTableName("JOBDETAIL", "HUMANRESOURCE_JOBDETAIL_");
        cd.setHistoryPolicy(policy);
    }

}

0 个答案:

没有答案