如何从使用maven插件的注释的现有实体生成DDL? [英] How can I generate DDL from existing entities with annotations using a maven plugin?
本文介绍了如何从使用maven插件的注释的现有实体生成DDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我该怎么做?
有没有可以生成DDL的maven插件?
我正在使用JPA(打开jpa )
解决方案
openjpa-maven-plugin插件提供了一个目标 sql
。使用此目标,可以从现有实体创建DDL。
< pluginManagement>
< plugin>
< groupId> org.apache.openjpa< / groupId>
< artifactId> openjpa-maven-plugin< / artifactId>
< version> 2.2.0< / version>
< configuration>
< includes> ** / entity / * .class< / includes>
< addDefaultConstructor> true< / addDefaultConstructor>
< connectionDriverName> com.ibm.db2.jcc.DB2Driver< / connectionDriverName>
< enforcePropertyRestrictions> true< / enforcePropertyRestrictions>
< persistenceXmlFile> $ {basedir} /src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
< skip> $ {skip.jpa}< / skip>
< sqlFile> $ {basedir} /src/main/resources/database.sql</sqlFile>
< / configuration>
<依赖关系>
<依赖关系>
< groupId> org.apache.openjpa< / groupId>
< artifactId> openjpa< / artifactId>
< version> 2.1.1< / version>
< / dependency>
<依赖关系>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-api< / artifactId>
< version> 1.6.6< / version>
< / dependency>
<依赖关系>
< groupId> org.slf4j< / groupId>
< artifactId> slf4j-simple< / artifactId>
< version> 1.6.6< / version>
< / dependency>
< / dependencies>
< / plugin>
< / pluginManagement>
< plugin>
< groupId> org.apache.openjpa< / groupId>
< artifactId> openjpa-maven-plugin< / artifactId>
<执行>
< execution>
< id> sql< / id>
< phase> generate-resources< / phase>
< goals>
< goal> sql< / goal>
< / goals>
< / execution>
< / executions>
< / plugin>
I have maven project and I want to generate DDL from existing entities.
How can I do that?
Is there any maven plugin that I can generate the DDL?
I am using JPA.(open jpa)
解决方案
openjpa-maven-plugin plugin provides a goal sql
. Using this goal, it is possible to create the DDL from existing entities.
<pluginManagement>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>2.2.0</version>
<configuration>
<includes>**/entity/ *.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<connectionDriverName>com.ibm.db2.jcc.DB2Driver</connectionDriverName>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
<persistenceXmlFile>${basedir}/src/main/resources/META-INF/persistence.xml</persistenceXmlFile>
<skip>${skip.jpa}</skip>
<sqlFile>${basedir}/src/main/resources/database.sql</sqlFile>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.6</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.6</version>
</dependency>
</dependencies>
</plugin>
</pluginManagement>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<executions>
<execution>
<id>sql</id>
<phase>generate-resources</phase>
<goals>
<goal>sql</goal>
</goals>
</execution>
</executions>
</plugin>
这篇关于如何从使用maven插件的注释的现有实体生成DDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文