简体   繁体   English

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

[英]How to use hibernate4-maven-plugin to generate multiple dialects schemas?

I wanna use the hibernate4-maven-plugin to generate the database schema in SQL. 我想使用hibernate4-maven-plugin在SQL中生成数据库模式。

But I have a condition: I wanna generate 3 schemas at time: 但是我有一个条件:我想一次生成3个模式:

  • one for Postgres, 一个用于Postgres,
  • one for Oracle and 一个用于Oracle,
  • another for SQL Server. 另一个用于SQL Server。

Here's my configuration: 这是我的配置:

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

I look at the official docs (link above), but it's not clearly if it's possible or not. 我看的是官方文档(上面的链接),但尚不清楚是否可行。

There is a way to do this with hibernate4-maven-plugin? 有没有办法用hibernate4-maven-plugin做到这一点?

Thanks! 谢谢!

You can create 3 executions from the plugin, each using a specific dialect 您可以从插件创建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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM