-->
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.  [ 8 posts ] 
Author Message
 Post subject: shemaexport target does not work :(
PostPosted: Sun Feb 27, 2005 10:55 am 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
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


Top
 Profile  
 
 Post subject: Re: shemaexport target does not work :(
PostPosted: Mon Feb 28, 2005 6:08 am 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
What is the problem with the question? Is it so difficult to be answered? Can someone answer me please. It is very important form me.


Top
 Profile  
 
 Post subject: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:13 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
Try this in your path ANT

<pathelement path="${myclass.directory}" />


Top
 Profile  
 
 Post subject: Re: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:19 am 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
jrpinna wrote:
Try this in your path ANT

<pathelement path="${myclass.directory}" />


Thank you for the aswer jrpinna!!!.

Where do I have to place this pathelement ? Can you give me an example?

Thank you in advance, kostas.


Top
 Profile  
 
 Post subject: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:21 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
In your build.xml

<!-- classpath -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
...
</fileset>
<pathelement path="the directory path of your generated classes" />
</path>


Top
 Profile  
 
 Post subject: Re: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:30 am 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
jrpinna wrote:
In your build.xml

<!-- classpath -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
...
</fileset>
<pathelement path="the directory path of your generated classes" />
</path>


OK I create the project.classpath path element. Do I have to use it inside the shemaexport element? Do I have to reference to this element?


Top
 Profile  
 
 Post subject: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:35 am 
Beginner
Beginner

Joined: Mon Jun 07, 2004 4:31 pm
Posts: 45
Location: France
An example of build.xml

...
<!-- classpath -->
<path id="project.classpath">
<fileset dir="${lib.dir}">
<include name="hibernate-2.1/*.jar"/>
<include name="hibernate-2.1/lib/*.jar"/>
<include name="mysql-connector-java-3.1.6/*.jar"/>
<include name="hibernate-extensions-2.1.3/tools/*.jar"/>
<include name="hibernate-extensions-2.1.3/tools/lib/*.jar"/>
</fileset>
<pathelement path="${gensrc.dir}" />
</path>

...

<!-- SQL schema generation -->
<target name="schemaexport" depends="compile">
<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="project.classpath">
</taskdef>

<schemaexport
properties="hibernate.properties"
quiet="false"
text="true"
drop="false"
delimiter=";"
output="${basedir}/schema-db.sql">
<fileset dir="${gensrc.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>


Top
 Profile  
 
 Post subject: Re: Schema export does not work
PostPosted: Mon Feb 28, 2005 7:55 am 
Newbie

Joined: Thu Jun 17, 2004 4:16 pm
Posts: 18
Sorry jrpinna it doesn't work :( I get the same message. What i did wat to add the path tag with the pathelement tag and use it in the classpathref of schemaexport tag!

I think the problem arise because the .hbm.xml and .java mapping javabean are not in the same. But I want tosave the .hbm.xml in another directory.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.