-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Some help using a hibernate.cfg.xml file
PostPosted: Thu Feb 24, 2005 7:55 pm 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
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 file
Code:
<?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 output
Code:
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 target
Code:
    <!-- 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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 9:56 am 
Beginner
Beginner

Joined: Wed Sep 17, 2003 10:43 am
Posts: 48
try a path relative to cfg.xml, or add the file: URI scheme.

Manos


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 11:06 am 
Newbie

Joined: Thu Mar 03, 2005 10:44 am
Posts: 1
kostas,
Did u ever get this problem sorted. I'm curious as I'm encountering the exact same error. Pls put me out of my misery.......!!!!

Paddy


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.