我目前正在使用 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/