Hi all,
I have a proble during the generation of the database schema. The direcory of my source is listed below:
Code:
-src
-conf
-hibernate.properties
-CC403.hbm.xml
-log4j.properties
-java
-essex.cc403.hbeans
-User.java
-Rank.java
Do you know what's wrong with the build.xml file? Just to mention that I use one *.hbm.xml file for all the generated classes.
Below I have the mapping xml file the build.xml as well the error result from command line.
Thank you in advance, kostas.
Hibernate version: hibernate-2.1.8
Ant Build.xml file:Code:
<?xml version="1.0" encoding="UTF-8"?>
<project name="CC403" default="default" basedir=".">
...
<!-- Teach Ant how to use Hibernate's code generation tool -->
<taskdef name="hbm2java"
classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask"
classpath="${javac.classpath}"/>
<!-- Generate the java code for all mapping files in our source tree -->
<target name="codegen" depends="init"
description="Generate Java source from the O/R mapping files">
<hbm2java output="${src.dir}">
<fileset dir="${conf.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>
<!-- Generate the schemas for all mapping files in our class tree -->
<target name="schema" depends="compile"
description="Generate DB schema from the O/R mapping files">
<!-- Teach Ant how to use Hibernate's schema generation tool -->
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpath="${javac.classpath}"/>
<schemaexport properties="${conf.dir}/hibernate.properties"
quiet="no" text="no" drop="no" delimiter=";">
<fileset dir="${conf.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
...
</project>
Mapping documents:Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class name="essex.cc403.hbeans.User" table="USER">
<meta attribute="class-description">
Represents a user in the database.
@author Konstantinos Karadamoglou
</meta>
<id name="id" type="int" column="USER_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="password" type="string" not-null="true"/>
<property name="firstName" type="string" not-null="true"/>
<property name="lastName" type="string" not-null="true"/>
<property name="addLine1" type="string" not-null="true"/>
<property name="addLine2" type="string" not-null="false"/>
<property name="city" type="string" not-null="true"/>
<property name="county" type="string" not-null="true"/>
<many-to-one name="rank" class="essex.cc403.hbeans.Rank" column="RANK_ID"/>
</class>
<class name="essex.cc403.hbeans.Rank" table="RANK">
<meta attribute="class-description">
Represents a rank in the database.
@author Konstantinos Karadamoglou
</meta>
<id name="rankID" type="int" column="RANK_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="name" type="string">
<meta attribute="use-in-tostring">true</meta>
<column name="NAME" not-null="true" unique="true" index="RANK_NAME"/>
</property>
<property name="canBook" type="boolean" not-null="true"/>
<property name="canDeleteAccount" type="boolean" not-null="true"/>
<property name="canViewBookings" type="boolean" not-null="true"/>
<property name="canEditBookings" type="boolean" not-null="true"/>
<property name="canCancelBookings" type="boolean" not-null="true"/>
<set name="Users" cascade="all" inverse="true" lazy="true">
<key column="RANK_ID"/>
<one-to-many class="essex.cc403.hbeans.User"/>
</set>
</class>
</hibernate-mapping>
Ant output:Code:
schema:
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
C:\Development\Projects\CVSProjects\CC403\build.xml:113: Schema text failed: net.sf.hibernate.MappingException: persistent class [essex.cc403.hbeans.User] not found
BUILD FAILED (total time: 7 seconds)
Name and version of the database you are using:
hsqldb-1.7.3.3