hibernate3-maven-plugin 配置

使用hibernate3-maven-plugin 可根据hibernate 或JPA的配置导出建表脚本,根据表结构导出java类,如下是根据JPA的配置信息导出建表脚本的例子:

 

 

<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>hibernate3-maven-plugin</artifactId>
				<version>2.2</version>
				<executions>
					<execution>
						<goals>
							<goal>hbm2ddl</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<components>
						<component>
							<name>hbm2ddl</name>
							<implementation>jpaconfiguration</implementation>
							<outputDirectory>src/main/db</outputDirectory>
						</component>
					</components>
					<componentProperties>
						<persistenceunit>PersistenceUnit</persistenceunit>
						<outputfilename>schema.ddl</outputfilename>
						<drop>false</drop>
						<create>true</create>
						<export>false</export>
						<format>true</format>
					</componentProperties>
				</configuration>
			</plugin>
 

其中persistenceunit 与persistence.xml文件的持久单元名称保持一致。

 

运行时使用 mvn:hibernate3:hbm2ddl

 

你可能感兴趣的:(hibernate3)