I'm trying to do a simple thing with hibernate3. I have a simple build.xml;
Code:
<?xml version="1.0"?>
<project name="example" basedir="." default="codegen">
<property name="src.dir" location="src" />
<property name="build.dir" location="classes" />
<property name="lib.dir" location="lib" />
<property name="source.generated" location="/src/com/dukenet/fms/hibernate" />
<property name="source.hibernate" location="/src/com/dukenet/fms/hibernate" />
<path id="toolslib">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="toolslib" />
<hibernatetool destdir="${source.generated}">
<configuration configurationfile="${src.dir}/hibernate.cfg.xml"/>
<hbm2java/>
</hibernatetool>
<target name="codegen"
description="Generate Java source code
from the Hibernate mapping files">
<hibernatetool/>
</target>
</project>
working with a simple hibernate.cfg.xml;
Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration. -->
<hibernate-configuration>
<session-factory>
<!-- properties -->
<!--<property name="connection.username">...
</property>
<pr <property name="database.script.file" value="${src.dir}/sql/${name}-mysql.sql"/>
<property name="database.driver.file" value="${lib.dir}/mysql-connector-java-3.0.14-production-bin.jar"/>
<property name="database.driver.classpath" value="${database.driver.file}"/>
<property name="database.driver" value="org.gjt.mm.mysql.Driver"/>
<property name="database.url" value="jdbc:mysql://localhost/facility"/>
<property name="database.userid" ...>operty name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>-->
....
org.gjt.mm.mysql.Driver</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<!-- mapping files -->
<mapping resource="com/dukenet/facility/hibernate/Facility.hbm.xml"/>
<mapping resource="com/dukenet/facility/hibernate/FacilityCategory.hbm.xml"/>
<mapping resource="com/dukenet/facility/hibernate/FacilityContract.hbm.xml"/>
<mapping resource="com/dukenet/facility/hibernate/FacilityEquipment.hbm.xml"/>
<mapping resource="com/dukenet/facility/hibernate/FacilityLocation.hbm.xml"/>
<mapping resource="com/dukenet/facility/hibernate/FacilityType.hbm.xml"/>
</session-factory>
</hibernate-configuration>
No matter what I do ant tells me it cannot locate Facility.hbm.xml;
Code:
<?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 package="com.dukenet.fms.hibernate.Facility">
<class table="FACILITY">
<id name="id" column="uid" type="long">
<generator class="increment"/>
</id>
<property name="date" type="timestamp"/>
<property name="name" column="name"/>
<one-to-one name="category" class="FacilityCategory"/>
<one-to-one name="type" class="FacilityType"/>
<!--Every Facility has a location-->
<set name="facilityLocation" >
<key column="id"/>
<one-to-many class="FacilityLocation"/>
</set>
</class>
</hibernate-mapping>
It is located in the com/dukenet/facility/hibernate directory relevant to the hibernate.cfg.xml. It doesn't seem to be able to find the Facility.hbm.xml no matter how explicitly I specify it.