下面的代碼片段爲特定數據庫生成創建/刪除sql,只要修改了JPA實體類即可。如何重複執行多次特定的執行
如何執行的東西相當於一個「的」操作,其中,在下面的代碼可用於生成所有支持的數據庫(如H2,MySQL和Postgres的)
目前我有修改數據庫的SQL .groupId,db.artifactId,db.driver.version每次生成SQL文件
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>${hibernate3-maven-plugin.version}</version>
<executions>
<execution>
<id>create schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<componentProperties>
<persistenceunit>${app.module}</persistenceunit>
<drop>false</drop>
<create>true</create>
<outputfilename>${app.sql}-create.sql</outputfilename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>drop schema</id>
<phase>process-test-resources</phase>
<goals>
<goal>hbm2ddl</goal>
</goals>
<configuration>
<componentProperties>
<persistenceunit>${app.module}</persistenceunit>
<drop>true</drop>
<create>false</create>
<outputfilename>${app.sql}-drop.sql</outputfilename>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-core.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>${slf4j-nop.version}</version>
</dependency>
<dependency>
<groupId>${db.groupId}</groupId>
<artifactId>${db.artifactId}</artifactId>
<version>${db.driver.version}</version>
</dependency>
</dependencies>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2dao</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2ddl</name>
<implementation>jpaconfiguration</implementation>
<outputDirectory>src/main/sql</outputDirectory>
</component>
<component>
<name>hbm2doc</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2hbmxml</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
</component>
<component>
<name>hbm2template</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
</configuration>
</plugin>
瑞奇 - 我有一個數據庫一次激活,我使用配置文件在它們之間切換。我不使用hbm2ddl.auto功能來動態生成我的SQL,但我使用hbm2ddl插件爲所有支持的數據庫生成腳本,並在啓動之前預加載它們。因此,我需要能夠在單次運行中爲所有支持的數據庫生成所有創建/刪除SQL。希望澄清。 – Joe 2009-09-07 14:30:00
好吧,我看到了問題,我還沒有配置來測試它。檢查插件代碼表明沒有內置機制來執行此操作 – 2009-09-07 21:42:19