hibernate - 在构建 hibernate 4.1.2 期间生成架构文件

标签 hibernate maven

我目前正在使用 Hibernate 3.6.9 和 hibernate3-maven-plugin。我使用目标 hbm2ddl 生成 sql 架构文件。

该插件不支持 Hibernate 4.1.2。如何生成架构文件?

最佳答案

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

示例:

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);

关于hibernate - 在构建 hibernate 4.1.2 期间生成架构文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10425041/

相关文章:

java - 使用 Struts 2 和 Hibernate 编辑行不起作用

java - Hibernate TransientPropertyValueException 在保存数据时

java - Maven 存储库包含错误的 cglib 源 jar

由于 java.net.UnknownHostException,Maven 元数据插件无法获取 maven-metadata.xml

testing - 使用给定目录的输入运行特定程序的脚本

java - 避免同一缓存区域的多次重新填充(由于并发)

java - 无法使用 START_ARRAY token 反序列化任务实例

java - Hibernate 按查询分组

java - 无法运行 Sonar 扫描

java - Spring 启动 : Handler dispatch failed; nested exception is java. lang.NoSuchMethodError