首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在hibernate 4.1.2的构建过程中生成架构文件

在hibernate 4.1.2的构建过程中生成架构文件
EN

Stack Overflow用户
提问于 2012-05-03 12:16:17
回答 1查看 1.3K关注 0票数 2

我现在使用的是Hibernate 3.6.9和hibernate3-maven-plugin。我使用目标hbm2ddl来生成一个sql schema文件。

该插件不支持Hibernate 4.1.2。如何生成模式文件?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-05-03 12:35:11

hibernate3-maven-plugin只是调用SchemaExport来生成模式文件。为什么不自己手动调用呢?

示例:

代码语言:javascript
复制
Configuration config = new Configuration();

Properties properties = new Properties();

properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect");
properties.put("hibernate.connection.url", "jdbc:postgresql://localhost:5432/Test"); 
properties.put("hibernate.connection.username", "username");
properties.put("hibernate.connection.password", "password");
properties.put("hibernate.connection.driver_class", "org.postgresql.Driver");
properties.put("hibernate.show_sql", "true");
config.setProperties(properties);

config.addAnnotatedClass(MyMappedPojo1.class);
config.addAnnotatedClass(MyMappedPojo2.class);
..................

SchemaExport schemaExport = new SchemaExport(config);

/**Just dump the schema SQLs to the console , but not execute them ***/
schemaExport.create(true, false);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10425041

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档