I'm going nuts trying to get a simple Envers example to work. I'm stuck on the org.hibernate.tool.ant.EnversHibernateToolTask
— it looks like I finally got all the jar files I needed, but now I get the error message
[hibernatetool] Persistence unit not found: 'ConsolePU'.
BUILD FAILED
C:\deka\proj\java\test-database\build.xml:61: Persistence unit not found: 'ConsolePU'.
As far as I can tell, persistence units are associated with JPA persistence.xml
files. But I'm not using a persistence.xml file; I'm using hibernate.cfg.xml — but the envers example has a <jpaconfiguration>
in the ant task:
<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>
is there something that I can replace it with to get it to work with the hibernate.cfg.xml file? There seems to be ZERO documentation on how to get all this stuff to work properly.
edit: OK, so the main problem was I didn't understand the hibernatetool options and what was appropriate for my app. I did find the Hibernate ant docs, fortunately. Thanks. Now I have a new problem: I'm using annotations, but I also have set up a hibernate.cfg.xml for the properties settings. The hibernatetool
task only lets me run either <configuration />
or <annotationconfiguration />
not both, and even <configuration />
won't work since I already have annotations doing things. How can I migrate my property settings from the hibernate.cfg.xml file to my annotations?
edit: Duh, I didn't realize you just do:
<annotationconfiguration configurationfile="...filename..." />
per the hibernatetool task docs.
Replace the <jpaconfiguration />
with the <configuration />
tag, as detailed in Hibernate Tools docs:
<configuration
configurationfile="hibernate.cfg.xml"
propertyfile="hibernate.properties"
entityresolver="EntityResolver classname"
namingstrategy="NamingStrategy classname">