Hibernate version: 3.3.1 GA
Using Ant, I am attempting to auto-generate the hibernate.cfg.xml file as part of my build process. In the past, I was using Xdoclet tags in my POJO's, and Xdoclet would generate the config files and DDL. I have moved to Hibernate 3, and I implemented EJB3 Annotations in the POJO's. I am using hbm2ddl successfully to generate the schema, but I can not figure out how to generate the hibernate.cfg.xml file. I need hbm2cfgxml to generate a file with "<mapping class="my.class"> for each of my POJO's, instead of generating individual .xbm.xml files, and "<mapping resource=class.xbm.xml" in the config file.
In essence, I'm attempting the following, by pointing directly to my POJO's:
Code:
<target name="hibernate.cfg.xml" depends="init">
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="xdoclet.class.path"
/>
<hibernatetool destdir="${build.class.dir}">
<property key="version" value="3.0" />
<property key="dataSource" value="${hibernate.datasource}" />
<property key="userName" value="${db.user}" />
<property key="password" value="${db.password}" />
<property key="useOuterJoin" value="${hibernate.outer.join}" />
<property key="dialect" value="${hibernate.dialect}" />
<property key="showSql" value="${hibernate.show.sql}" />
<annotationconfiguration configurationfile="${build.class.dir}/hibernate.cfg.xml">
<fileset dir="${java.dir}">
<include name="**/domain/**/*.java" />
</fileset>
</annotationconfiguration>
<hbm2cfgxml ejb3="true" />
</hibernatetool>
</target>
This fails with a "Content is not allowed in prolog." error, attempting to parse the POJO, as it seems to only support the xbm.xml files. Also, if I attempt to do this from scratch, I get a "hibernate.cfg.xml file not found" error. I must place a template config file there first, then this will run and regenerate a new file.
Am I going about this completely wrong? I really appreciate any help on this.
Thanks!