休眠文档显示非常清晰how to configure Hibernate with XML。如何使用JPA 2.0文件配置Hibernate?
这是代码段的可以这样做:
new Configuration().configure("catdb.cfg.xml")
现在,你如何配置Hibernate Hibernate配置文件,而不是时,你有一个JPA 2.0配置文件?
- 如何为META-INF/persistence.xml做到这一点?
- 如果我的文件名为META-INF/jpa.xml,该怎么办?
这是用于Hibernate 3.6和JPA 2.0的。我的最终目标是能够为文件persistence.xml中描述的类导出模式DDL,所以我不想构建SessionFactory。
Configuration cfg = /* ??? */
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.setDelimiter(";");
schemaExport.setOutputFile("ddl.sql");
boolean script = true, export = false, justDrop = false, justCreate = false;
schemaExport.execute(script, export, justDrop, justCreate);