max wrote:
Did you actually try and go to tools.hibernate.org and read the docs ?
afaik we don't have any hbm2java explanation in chapter 4 of the core reference guide it is all in the *tools* doc.
Yes I have.
The Chapter 4 I'm referring to is in the Hibernate Tools Reference - Ant Tools.
It leads me to suspect that my Ant file should look something like the following:
============
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." default="compile" name="connectHub-build">
<property name="src.dir" value="${basedir}/src"/>
<property name="mappings.dir" value="${basedir}/mappings"/>
<property name="gensrc.dir" value="${basedir}/gensrc"/>
<property name="config.dir" value="${basedir}/config"/>
<property name="dest.dir" value="${basedir}/classes"/>
<property name="libs.dir" value="${basedir}/libs"/>
<path id="hibernate.tools.libraries">
<fileset dir="${libs.dir}">
<include name="hibernate-tools.jar"/>
<include name="hibernate3.jar"/>
<include name="commons-logging-1.0.4.jar"/>
<include name="dom4j-1.6.1.jar"/>
<include name="commons-collections-2.1.1.jar"/>
<include name="ojdbc14.jar"/>
<include name="velocity-1.4.jar"/>
<include name="velocity-tools-generic-1.1.jar"/>
<include name="jtidy-r8-21122004.jar"/>
</fileset>
</path>
<target name="copy-resources">
<copy todir="${dest.dir}">
<fileset dir="${mappings.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
<fileset dir="${config.dir}">
<include name="hibernate.cfg.xml"/>
</fileset>
</copy>
</target>
<taskdef
name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="hibernate.tools.libraries"/>
<taskdef
name="hbm2java"
classname="org.hibernate.tool.ant.Hbm2JavaExporterTask"
classpathref="hibernate.tools.libraries"/>
<target name="codegen" depends="copy-resources">
<hibernatetool destdir="${gensrc.dir}">
<classpath refid="project.classpath"/>
<configuration configurationfile="${config.dir}/hibernate.cfg.xml">
<fileset dir="${mappings.dir}">
<include name="Xxx.hbm.xml"/>
</fileset>
</configuration>
<!--<hbm2doc></hbm2doc>-->
<hbm2java jdk5="true" ejb3="false"/>
</hibernatetool>
</target>
</project>
============
But this fails with the bizarre error that:
class Xxx not found while looking for property: xxxSID
which in turn is caused by:
ClassNotFoundException: Xxx
which is rather odd as I have manually created Xxx.hbm.xml from which I'm trying to generate Xxx.java and then Xxx.class.
The Xxx.hbm.xml file:
===========
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class
name="Xxx"
table="XXX">
<meta attribute="class-description">
Javadoc for the Xxx class
@author David Franklin
</meta>
<id name="xxxSID" column="SID">
<generator class="sequence">
<param name="sequence">XXX_SEQ</param>
</generator>
</id>
</class>
</hibernate-mapping>
===========
Something somewhere is going very wrong and I have spent several days going round in circles with this.
I would greatly appreciate some specific suggestions as to what the problem might be.
I am using Hibernate 3.1 and the latest Hibernate Tools beta.
David