【发布时间】:2011-05-24 14:19:49
【问题描述】:
Hibernate 文档非常清楚地显示 how to configure Hibernate with XML。
这是执行此操作的代码的 sn-p:
new Configuration().configure("catdb.cfg.xml")
现在当你有一个 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);
【问题讨论】:
标签: hibernate jpa persistence