java - 如何使用 hibernate4-maven-plugin 生成多种方言模式?

标签 java sql hibernate maven maven-plugin

我想使用hibernate4-maven-plugin以 SQL 生成数据库架构。

但我有一个条件:我想一次生成 3 个模式:

  • 一个用于 Postgres,
  • 一个用于 Oracle,
  • 另一个用于 SQL Server。

这是我的配置:

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

我查看了官方文档(上面的链接),但不清楚是否可能。

有办法用 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>

关于java - 如何使用 hibernate4-maven-plugin 生成多种方言模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28615977/

相关文章:

Java浮点到IEEE-754十六进制?

java - 最终关键字的优化

java - Intellij 插件创建后在编辑器中打开新类

mysql - 查询以检查某一行是否有 2 个单词

java - 使用 Junit 在 hbm2dll 上测试 HQL 查询

java - 在Java中使用Http连接时,为什么我们总是应该在写入之前进行读取调用?

sql - 如何使用 4 部分命名约定在 "updates statistics"作业中调用链接服务器?

asp.net - 将 Linq 转换为 SQL

java - Hibernate 加入两个不相关的表,当两个表都有复合主键时

hibernate - 在长时间运行的对话中在 Wicket 和 Hibernate 之间安全地传递信息