ITeye博客

hibernate3-maven-plugin 配置

kabuka · 2012-04-06 17:17 · jpa · 编程语言 · Markdown

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

评论(1)

  1. #1 楼 · carlos · 2012-12-13 10:01

    :lol: :wink: :x :) :D :oops: :? 8) :P

评论功能维护中,当前仅展示历史评论。