下面的代码片段为特定数据库生成创建/删除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