我现在使用的是Hibernate 3.6.9和hibernate3-maven-plugin。我使用目标hbm2ddl来生成一个sql schema文件。
该插件不支持Hibernate 4.1.2。如何生成模式文件?
发布于 2012-05-03 12:35:11
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);https://stackoverflow.com/questions/10425041
复制相似问题