-->
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.  [ 7 posts ] 
Author Message
 Post subject: schemaexport - hbm.xml's not found
PostPosted: Mon Aug 01, 2005 10:06 pm 
Newbie

Joined: Mon Aug 01, 2005 9:52 pm
Posts: 6
Hibernate version: 2.1

I am trying to use Ant and hbm2ddl's SchemaExportTask and am getting an error because hbm.xml's are not found.

Can anyone give me some advice?

Thanks

----------------------------------------------------------------------------------

TaskDef:

<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="classpath" />

----------------------------------------------------------------------------------

Task:

<target name="schemaexport" depends="hibernate">
<schemaexport config="${basedir}/src/main/hibernate.cfg.xml">
<fileset dir="${src.dir}" includes="**/*.hbm.xml"/>
</schemaexport>
</target>

----------------------------------------------------------------------------------

hibernate.cfg.xml :

<?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>

<session-factory>
<!--properties for jdbc connection here
removed for forum post-->

<mapping resource="info/matthewryan/faq/entity/Category.hbm.xml"/>
<mapping resource="info/matthewryan/faq/entity/Faq.hbm.xml"/>
</session-factory>

</hibernate-configuration>

----------------------------------------------------------------------------------

Ant Console Output:

schemaexport:
[schemaexport] (cfg.Environment 478 ) Hibernate 2.1.7
[schemaexport] (cfg.Environment 507 ) hibernate.properties not found
[schemaexport] (cfg.Environment 538 ) using CGLIB reflection optimizer
[schemaexport] (cfg.Environment 567 ) using JDK 1.4 java.sql.Timestamp handling
[schemaexport] (cfg.Configuration 934 ) configuring from file: hibernate.cfg.xml
[schemaexport] (cfg.Configuration 331 ) Mapping resource: info/matthewryan/faq/entity/Category.hbm.xml

BUILD FAILED
C:\Downloads\MATTHEW\projects\faq\build.xml:164: Schema text failed: Resource: info/matthewryan/faq/entity/Category.hbm.xml not found


Top
 Profile  
 
 Post subject: Re: schemaexport - hbm.xml's not found
PostPosted: Tue Aug 02, 2005 6:58 am 
Beginner
Beginner

Joined: Tue Jul 19, 2005 4:03 am
Posts: 34
Location: Aberdeen, UK
Hi!

I’m using the Schema Generator with the hibernate.properties configuration file, not the hibernate.cfg.xml. I think I did this because I got the same error message as you.

Create a hibernate.properties file and change your target to something like this:

Code:
<target name="schemaexport" depends="hibernate">
   <schemaexport config="${basedir}/src/main/hibernate.properties">
      <fileset dir="${src.dir}" includes="**/*.hbm.xml"/>
   </schemaexport>
</target>

Hope this helps


Top
 Profile  
 
 Post subject: RE : schemaexport - hbm.xml's not found
PostPosted: Tue Aug 02, 2005 8:08 am 
Newbie

Joined: Mon Aug 01, 2005 9:52 pm
Posts: 6
I changed the target to this:

Code:
<target name="schemaexport" depends="hibernate">
   <schemaexport properties="${basedir}/src/main/hibernate.properties">
      <fileset dir="${src.dir}" includes="**/*.hbm.xml"/>
   </schemaexport>
</target>

and I got this message:


Code:
[schemaexport] (cfg.Configuration                         255 ) Could not compile mapping document
[schemaexport] net.sf.hibernate.MappingException persistent class [info.matthewryan.faq.entity.Category] not found
[schemaexport] at net.sf.hibernate.cfg.Binder.bindClass(Binder.java:85)


Top
 Profile  
 
 Post subject: Re: RE : schemaexport - hbm.xml's not found
PostPosted: Tue Aug 02, 2005 8:20 am 
Beginner
Beginner

Joined: Tue Jul 19, 2005 4:03 am
Posts: 34
Location: Aberdeen, UK
This is the target I use:

Code:
<target name="schema" depends="codegen, compile" description="Generate DB schema from the O/R mapping files">
        <taskdef name="schemaexport"
            classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
            <classpath>
                <pathelement location="${build.dir}/classes" />
                <path refid="project.classpath"/>
            </classpath>
        </taskdef>
       
        <schemaexport properties="${basedir}/resources/hibernate/config/hibernate.properties"
            quiet="no"
            text="no"
            drop="no">
            <fileset dir="${map.dir}">
                <include name="**/*.hbm.xml"/>
            </fileset>
        </schemaexport>
    </target>



I think this issue is because the net.sf.hibernate.tool.hbm2ddl.SchemaExportTask needs a reference to compiled classes in addition to the jar files, which is set in line 5 in my target


Top
 Profile  
 
 Post subject: schemaexport - hbm.xml's not found
PostPosted: Fri Aug 05, 2005 2:12 am 
Newbie

Joined: Mon Aug 01, 2005 9:52 pm
Posts: 6
Adding the classpath for the classes fixed that error.

The Ant build script runs without error, the DDL file is written to disk.

However the file is empty.......

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 06, 2005 12:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
text="yes"


Top
 Profile  
 
 Post subject: schemaexport - hbm.xml's not found
PostPosted: Sat Aug 06, 2005 3:06 am 
Newbie

Joined: Mon Aug 01, 2005 9:52 pm
Posts: 6
Bingo!


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