我正在尝试升级到Hibernate 4.1.3 (从3.6.9)。模型是基于注解的(也就是说,持久化类是用@Entity和@Column注解定义的)
maven构建使用hibernate3-maven-plugin为模式创建sql脚本,但该插件不能与4.1.3一起使用。我想过使用SchemaExportTask vi antrun,但我的理解是,我需要显式地配置要分析的类,而我不知道如何在maven中获得它们。那么我该如何为类提供任务呢?
任何其他创建模式的帮助都将是非常好的。
发布于 2014-02-17 10:04:13
Juplo创建了Maven plugin for Hibernate 4。该插件自动扫描您的项目以查找带注释的类,并支持模式导出(包括Envers )。工作示例如下所示。查看official plugin configuration documentation以获取有关所用选项的更多信息。
该插件在test goal上的Maven /target目录中生成schema.sql文件。或者,您可以手动运行hibernate4:export goal来更新文件。
<project>
<build>
<plugins>
<plugin>
<groupId>de.juplo</groupId>
<artifactId>hibernate4-maven-plugin</artifactId>
<version>1.0.3</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
<configuration>
<envers>true</envers>
<format>true</format>
<delimiter>;</delimiter>
<force>true</force>
<type>CREATE</type>
<target>SCRIPT</target>
<hibernateDialect>org.hibernate.dialect.PostgreSQL9Dialect</hibernateDialect>
</configuration>
</plugin>
</plugins>
</build>
</project>https://stackoverflow.com/questions/10895622
复制相似问题