我要疯了,试图让一个简单的Envers示例工作。我被困在了org.hibernate.tool.ant.EnversHibernateToolTask
——看起来我终于得到了我需要的所有 jar 文件,但现在我收到了错误消息
[hibernatetool] Persistence unit not found: 'ConsolePU'.
BUILD FAILED
C:\deka\proj\java\test-database\build.xml:61: Persistence unit not found: 'ConsolePU'.
据我所知,持久性单元与 JPApersistence.xml
文件相关联。但我没有使用persistence.xml 文件;我正在使用 hibernate.cfg.xml - 但 envers 示例<jpaconfiguration>
在 ant 任务中有一个:
<hibernatetool destdir=".">
<classpath>
<fileset dir="src/">
<include name="**/*.hbm.xml"/>
</fileset>
<path location="${buildDir}" />
</classpath>
<jpaconfiguration persistenceunit="ConsolePU" />
<hbm2ddl
drop="false"
create="true"
export="false"
outputfilename="versioning-ddl.sql"
delimiter=";"
format="true"/>
</hibernatetool>
有什么可以替换它以使其与 hibernate.cfg.xml 文件一起使用吗?似乎有关于如何让所有这些东西正常工作的零文档。
编辑:好的,所以主要问题是我不了解 hibernatetool 选项以及什么适合我的应用程序。幸运的是,我确实找到了Hibernate ant 文档。谢谢。现在我有一个新问题:我正在使用注释,但我还为属性设置设置了一个 hibernate.cfg.xml。该hibernatetool
任务只能让我运行其中一个<configuration />
或<annotationconfiguration />
两个都不运行,甚至<configuration />
无法工作,因为我已经有注释在做事。如何将我的属性设置从 hibernate.cfg.xml 文件迁移到我的注释?
编辑:呃,我没有意识到你只是这样做:
<annotationconfiguration configurationfile="...filename..." />