Hi
I'm using hibernate 3.2 and a night build of hibernate tools "HibernateTools-3.2.0.200708311701-nightly"
I'm trying to make a simple example of class generation using the following mapping
<hibernate-mapping auto-import="true"
package="com.corvantis.test1.domain">
<class name="Product">
<id name="id" column="id">
<generator class="native"/>
</id>
<property name="name" column="name" type="String" length="40"/>
<property name="description" column="description" type="String" length="4000"/>
<property name="price" column="price" type="double" />
</class>
</hibernate-mapping>
the following ant script
<project name="test1" default="codegen" basedir=".">
<property name="lib.dir" value="lib"/>
<property name="src.dir" value="src"/>
<property name="src.hibernate" value="src"/>
<property name="source.generated" value="generated"/>
<path id="class.path">
<path location="${lib.dir}/hibernate-tools.jar"/>
<path location="${lib.dir}/hibernate3.jar"/>
<path location="${lib.dir}/freemarker.jar"/>
<path location="${lib.dir}/postgresql-8.2-506.jdbc3.jar"/>
<path location="${lib.dir}/commons-logging.jar"/>
<path location="${lib.dir}/commons-collections.jar"/>
<path location="${lib.dir}/dom4j-1.6.1.jar"/>
</path>
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="class.path"/>
<target name="codegen">
<hibernatetool destdir="${src.dir}">
<classpath>
<path location="${lib.dir}"/>
<path location="${src.dir}"/>
</classpath>
<configuration configurationfile="hibernate.cfg.xml">
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>
<hbm2java/>
</hibernatetool>
</target>
</project>
and the following hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/test1</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">postgres</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<mapping resource="test1.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Running "codegen" task I get the follwing error
INFO: Mapping class: com.corvantis.test1.domain.Product -> Product
An exception occurred while running exporter #2:hbm2java (Generates a set of .java files)
org.hibernate.InvalidMappingException: Could not parse mapping document from resource test1.hbm.xml
org.hibernate.MappingException: class com.corvantis.test1.domain.Product not found while looking for property: id
java.lang.ClassNotFoundException: com.corvantis.test1.domain.Product
A class were not found in the classpath of the Ant task.
Ensure that the classpath contains the classes needed for Hibernate and your code are in the classpath.
I don't understand why the task is looking for the Product class if this is the class that I want to generate, I'm completely sure that I'm doing something wrong any help will be preciated, two years ago I worked with hibernate and was pretty cool now I want to keep in touch again with this fabulous technology.
Best regards Rodney
|