-->
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: schemaexport taskdef fails to find .hbm.xml file
PostPosted: Wed Nov 19, 2003 3:19 am 
Newbie

Joined: Wed Nov 19, 2003 3:00 am
Posts: 7
Location: Madison, Wisconsin, USA
I'm having a strange problem with the schemaexport Ant taskdef, which I'd like to use. When I run it, my mapping file isn't found, and I end up with an empty schema. However, when I "manually" run the SchemaExport tool using what seems to be an equivalent java task in the same build.xml, I can get it to work by explicitly listing the filename.

Since this defeats the purpose of the "**/*.hbm.xml" wildcard, I'd really like to get the taskdef-based target working. Has anyone seen a problem like this, or can someone help me figure out what I'm doing wrong?

Here are the relevant excerpts from the build.xml. The target that works is "schema2", the one that doesn't is the preceding one, "schema" (both depend on a "compile" task I've omitted for brevity; that just compiles the Java classes to the classes directory, and works fine):

Code:
<project name="Hibernate Examples" default="schema" basedir=".">

  <!-- Set up properties containing important project directories -->
  <property name="source.root" value="src"/>
  <property name="class.root" value="classes"/>
  <property name="lib.dir" value="lib"/>
  <property name="data.dir" value="data"/>

  <!-- Set up the class path for compilation and execution -->
  <path id="project.class.path">
      <!-- Include our own classes, of course -->
      <pathelement location="${class.root}" />
      <!-- Include jars in the project library directory -->
      <fileset dir="${lib.dir}">
        <include name="**/*.jar"/>
      </fileset>
  </path>

  <!-- Teach Ant how to use Hibernate's schema generation tool -->
  <taskdef name="schemaexport"
           classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
           classpathref="project.class.path"/>

  <!-- Create our necessary subdirectories, and copy resources into them. -->
  <target name="prepare" description="Sets up build structures">
    <mkdir dir="${class.root}"/>

    <!-- Copy in our property files and O/R mappings for use at runtime -->
    <copy todir="${class.root}" >
      <fileset dir="${source.root}" >
        <include name="**/*.properties"/>
        <include name="**/*.hbm.xml"/>
      </fileset>
    </copy>
  </target>

  <!-- Generate the schemas for all mapping files in our source tree -->
  <target name="schema" depends="compile"
          description="Generate DDL for schema from the O/R mapping files">
    <schemaexport properties="${class.root}/hibernate.properties"
                  quiet="no" text="yes" drop="no" delimiter=";"
                  output="${data.dir}/schema-export.ddl"/>
      <fileset dir="${class.root}">
        <include name="**/*.hbm.xml"/>
      </fileset>
  </target>

  <target name="schema2" depends="compile"
          description="Generate DDL for schema from the O/R mapping files">
    <java classname="net.sf.hibernate.tool.hbm2ddl.SchemaExport"
          failonerror="true" fork="true">
      <arg value="--text"/>
      <arg value="--delimiter=;"/>
      <arg value="--properties=${class.root}/hibernate.properties"/>
      <arg value="--output=${data.dir}/my_schema.ddl"/>
      <arg value="${class.root}/com/brunchboy/hh/Track.hbm.xml"/>
      <classpath refid="project.class.path"/>
    </java>
  </target>

</project>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2003 3:33 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Code:
<schemaexport properties="${class.root}/hibernate.properties"
                  quiet="no" text="yes" drop="no" delimiter=";"
                  output="${data.dir}/schema-export.ddl"/>
      <fileset dir="${class.root}">
        <include name="**/*.hbm.xml"/>
      </fileset>


Should be
Code:
<schemaexport properties="${class.root}/hibernate.properties"
                  quiet="no" text="yes" drop="no" delimiter=";"
                  output="${data.dir}/schema-export.ddl">
      <fileset dir="${class.root}">
        <include name="**/*.hbm.xml"/>
      </fileset>
</schemaexport>


shouldn't it ?

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Good catch!
PostPosted: Wed Nov 19, 2003 10:42 am 
Newbie

Joined: Wed Nov 19, 2003 3:00 am
Posts: 7
Location: Madison, Wisconsin, USA
Wow, yes, it should indeed. I'm amazed Ant didn't complain about that floating fileset that did nothing.

Once I fixed the structure of the target, in fact it works just like it should. I knew it had to be something wrong, I just couldn't see it since I knew what I was trying to express.

Thanks!


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.