Why does the hbm2java task require my class files in order to generate POJO files from the mapping file? This defeats the purpose of autogenerating the .java files if I have to already have the class files! I must be doing something wrong, as this can't be the logical way of doing this...
Here's what I mean; I have the following build.xml task:
Code:
<!-- Hibernate Tools import -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath"/>
<!-- Auto create POJOs from mapping file -->
<target name="hibernate">
<hibernatetool destdir="${build.dir}\gen">
<configuration configurationfile="${src.cfg.dir}/hibernate.cfg.xml"/>
<hbm2java jdk5="true"/>
</hibernatetool>
</target>
And when I run it I get the following error:
Code:
[hibernatetool] org.hibernate.InvalidMappingException: Could not parse mapping d
ocument from resource OracleVars.hbm.xml
[hibernatetool] org.hibernate.MappingException: class Workstations not found whi
le looking for property: Actions
[hibernatetool] java.lang.ClassNotFoundException: com.pac.server.common.oraclevars.Workstations
[hibernatetool] A class were not found in the classpath of the Ant task.
[hibernatetool] Ensure that the classpath contains the classes needed for Hibern
ate and your code are in the classpath.
My mapping file contains very basic sections, like so:
Code:
<class name="com.pac.server.common.oraclevars.Workstations" table="WORKSTATIONS">
<id name="id" type="int" column="ID" >
<generator class="assigned"/>
</id>
<property name="Actions">
<column name="ACTIONS"/>
</property>
</class>
I don't understand why hibernate-tools cares about finding my class in order to create the POJOs. Shouldn't it simply use the hbm.xml information to generate the .java files itself?