如何使用 hibernate4-maven-plugin 生成多种方言模式?
How to use hibernate4-maven-plugin to generate multiple dialects schemas?
我想使用 hibernate4-maven-plugin 在 SQL 中生成数据库模式。
但我有一个条件:我想同时生成3个模式:
- 一个用于 Postgres,
- 一个用于 Oracle 和
- 另一个 SQL 服务器。
这是我的配置:
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<hibernateDialect>org.hibernate.dialect.PostgreSQLDialect</hibernateDialect>
<!-- I want generate the schemas for these dialects too, at same time... -->
<!-- <hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>-->
<!-- <hibernateDialect>org.hibernate.dialect.SQLServerDialect</hibernateDialect>-->
<target>SCRIPT</target>
</configuration>
</plugin>
我看了官方文档(link上面的),但不清楚是否可以。
有没有办法用 hibernate4-maven-plugin 做到这一点?
谢谢!
您可以从插件中创建 3 个执行,每个都使用特定的方言
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<!-- postgres -->
<execution>
<id>postgres</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.PostgreSQLDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/postgres-schema.sql.</outputFile>
</configuration>
</execution>
<!-- oracle -->
<execution>
<id>oracle</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/oracle-schema.sql.</outputFile>
</configuration>
</execution>
<!-- sql-server -->
<execution>
<id>sql-server</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.SQLServerDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/sqlserver-schema.sql.</outputFile>
</configuration>
</execution>
</executions>
我想使用 hibernate4-maven-plugin 在 SQL 中生成数据库模式。
但我有一个条件:我想同时生成3个模式:
- 一个用于 Postgres,
- 一个用于 Oracle 和
- 另一个 SQL 服务器。
这是我的配置:
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<hibernateDialect>org.hibernate.dialect.PostgreSQLDialect</hibernateDialect>
<!-- I want generate the schemas for these dialects too, at same time... -->
<!-- <hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>-->
<!-- <hibernateDialect>org.hibernate.dialect.SQLServerDialect</hibernateDialect>-->
<target>SCRIPT</target>
</configuration>
</plugin>
我看了官方文档(link上面的),但不清楚是否可以。
有没有办法用 hibernate4-maven-plugin 做到这一点?
谢谢!
您可以从插件中创建 3 个执行,每个都使用特定的方言
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<!-- postgres -->
<execution>
<id>postgres</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.PostgreSQLDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/postgres-schema.sql.</outputFile>
</configuration>
</execution>
<!-- oracle -->
<execution>
<id>oracle</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.Oracle10gDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/oracle-schema.sql.</outputFile>
</configuration>
</execution>
<!-- sql-server -->
<execution>
<id>sql-server</id>
<goals>
<goal>export</goal>
</goals>
<configuration>
<hibernateDialect>org.hibernate.dialect.SQLServerDialect</hibernateDialect>
<target>SCRIPT</target>
<outputFile>${project.build.directory}/sqlserver-schema.sql.</outputFile>
</configuration>
</execution>
</executions>