-->
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.  [ 5 posts ] 
Author Message
 Post subject: Creating schema from an Ant task
PostPosted: Thu Oct 21, 2004 11:56 pm 
Newbie

Joined: Thu Oct 21, 2004 11:26 pm
Posts: 1
Hello,

I am using Hibernate 2.1, and trying to use the SchemaExport task to automatically create some tasks. It doesn't seem to be working. Here's what I have in my build.xml:

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

<target name="schemaexport" description="Generate the SQL schema">
<schemaexport
config="extras/hibernate_export.cfg.xml"
quiet="no"
text="yes" drop="yes"
delimiter=";"
output="extras/schema-export.sql">
<fileset dir="src">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>

When I run this, I get:

BUILD FAILED
/home/chiral/mobilespace/build.xml:69: Schema text failed: Resource: chiralsoftware/mypackage/Site.hbm.xml not found

But the Site.hbm.xml file exists, in both the src and classes directories.

Does the SchemaExport task actually work? Or should I just use Ant's java task to execute the Hibernate schema export Java code directly, and not even bother with the Ant task? If someone could confirm that the schemaexport Ant task actually works, that would be much appreciated. And if it does work, I would love to know how to use it in this build file.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 9:55 am 
Newbie

Joined: Thu Apr 29, 2004 11:40 am
Posts: 11
I'm having the same problem...

Ant task:
Code:
<schemaexport
    config="webroot/WEB-INF/classes/hibernate.cfg.xml"
    quiet="no"
    text="no"
    drop="no"
    delimiter=";"
    output="ant/schema-export.sql">
          <fileset dir="webroot/WEB-INF/classes" >
     <include name="**/*.hbm.xml"/>
          </fileset>
</schemaexport>


hibernate.cfg.xml
Code:
...
<mapping resource="com/pg/webcc/contract/Contract.hbm.xml" />
...


error:

BUILD FAILED:
build.xml:26: Schema text failed: Resource: com/pg/webcc/contract/Contract.hbm.xml not found


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 10:07 am 
Newbie

Joined: Thu Apr 29, 2004 11:40 am
Posts: 11
Ah,
I found that by adding:


<pathelement location="webroot/WEB-INF/classes"/>


to my


<path id="class.path">
<fileset dir="webroot/WEB-INF/lib">
<include name="*.jar" />
</fileset>
<pathelement location="webroot/WEB-INF/classes"/>
</path>


things get happy ;)[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 11:56 am 
Newbie

Joined: Tue Aug 16, 2005 3:39 pm
Posts: 2
I'm using Hibernate 3.0.5, and I can't get the ant task to execute as well.

Considering the example in the documentation (section 21.1.4 and 21.1.6) gives the examples:

<target name="schemaexport">
<taskdef name="schemaexport"
classname="org.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="class.path"/>

<schemaexport
properties="hibernate.properties"
quiet="no"
text="no"
drop="no"
delimiter=";"
output="schema-export.sql">
<fileset dir="src">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>

<target name="schemaupdate">
<taskdef name="schemaupdate"
classname="org.hibernate.tool.hbm2ddl.SchemaUpdateTask"
classpathref="class.path"/>

<schemaupdate
properties="hibernate.properties"
quiet="no">
<fileset dir="src">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaupdate>
</target>

Which is CLEARLY WRONG because classpathref="class.path" in the taskdef tag isn't defined within the target at all... Maybe someone could actually take the time to make the documentation correct?

I've tried what I think is every combination of classpath, pathelement, and path. The schemaexport task takes a fileset of the hbm.xml configuration files, but for some reason won't find any "classpath" to find the resources specified in the hibernate.cfg.xml file.

Another good question - why do I need to specify which hbm.xml files when the hibernate.cfg.xml file already specifies the <mapping resource="whatever.hbm.xml"/> mappings?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 12:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Use the regular forum.


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