如何使用Eclipse Link
在运行时将数据库模式与JPA实体进行比较答案 0 :(得分:0)
目前尚不清楚您的目标是什么,但我使用会话自定义程序在需要时运行验证:
public class ValidationCustomizer implements SessionCustomizer {
public void customize(Session session) {
IntegrityChecker checker = new IntegrityChecker();
checker.catchExceptions();
checker.checkDatabase();
session.setIntegrityChecker(checker);
}
}
然后将其添加到持久性单元:
properties.put("eclipselink.session.customizer", "packagename.ValidationCustomizer");
EntityManagerFactory emFactory = Persistence.createEntityManagerFactory(NAME, properties);