Hibernate version:
2.1.8
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>
Name and version of the database you are using:HSQLDB 1.7.3.3
Hibernate configuration fileCode:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
<!-- a SessionFactory instance listed as /jndi/name -->
<session-factory>
<!-- properties -->
<property name="dialect">net.sf.hibernate.dialect.HSQLDialect</property>
<property name="show_sql">true</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:C:/Development/Projects/CC403/data/cc403</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<!-- mapping files -->
<mapping resource="C:/Development/Projects/CVSProjects/CC403/src/conf/CC403.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Ant command line outputCode:
init:
build:
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:82: Schema text failed: Resource: C:/Development/Projects/CVSProjects/CC403/src/conf/CC403.hbm.xml not found
BUILD FAILED (total time: 0 seconds)
Ant targetCode:
<!-- Generate the schemas for all mapping files in our class tree -->
<target name="schema" depends="build"
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"
classpathref="project.classpath"/>
<schemaexport config="C:/Development/Projects/CVSProjects/CC403/src/conf/hibernate.cfg.xml"
quiet="no" text="no" drop="no" delimiter=";">
<fileset dir="${source.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
Hello this is my first time that I use a hibernate.cfg.xml file. I used to use hibernate.properties files. The reason of this change is that i want to keep the mapping properties of each class in one file.
Now about my problem. I dont know how to use SchemaExport with a hibernate.cfg.xml. Can you view the above ant target which tries to create a db schema. Is it correct? Where can I find information about using the cfg.xml file properly?
As you can see from the attached ant output, the target cannot find the mapping xml file regardless the fact that i entered a full path. (I checked a lot of times about the correctness of the path). Why it doesn't find the file.
thank you in advance kostas