I have the specified the following composite-id element in one of my Hibernate configuration files:
Code:
<composite-id name="id" class="com.foo.BarId">
<key-many-to-one name="xxxId" class="Xxx" column="xxx_id"/>
<key-many-to-one name="yyyId" class="Yyy" column="yyy_id"/>
</composite-id>
When I run the "hbm2java" tool via an Ant build.xml file, the "com.foo.BarId" class file is not being generated automatically.
I assume that the "com.foo.BarId" class file should be created by the Hibernate tool (though I get by by creating it manually).
Can anyone please tell me what I might be doing wrong?
The "hbm2java" tool otherwise appears to work successfully: I have several configuration files (without composite IDs) and they are all generated as expected.
I am using Hibernate tools version 3.2.4.GA and Hibernate version 3.2.5.ga.
My ant build.xml file is set with following entries that enable the use of the Hibernate Tools via Maven:
Code:
<path id="maven-ant-tasks.classpath" location="libraries/maven-ant-tasks-2.0.9.jar"/>
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="maven-ant-tasks.classpath">
</typedef>
<artifact:pom file="pom.xml" id="maven.pom" />
<artifact:dependencies pathId="dependency.classpath">
<pom refid="maven.pom"/>
</artifact:dependencies>
And the Hibernate Tools task is defined in the prescribed way, as follows:
Code:
<target name="initialise-hibernatetool" description="Initialise Hibernate Tools task">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="dependency.classpath"/>
</target>
The "hbm2java" tool is then called as follows:
Code:
<target name="hibernate-generate-java-classes" depends="initialise-hibernatetool">
<hibernatetool destdir="src">
<configuration configurationfile="hibernate/hibernate.cfg.xml"/>
<classpath>
<path location="hibernate"/>
</classpath>
<hbm2java/>
</hibernatetool>
</target>
TIA
Harry Mantheakis
London, UK