• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
  • Carey Brown
  • salvin francis
  • Claude Moore

Where is documentation for ant task schemaexport  RSS feed

Ranch Hand
Posts: 420
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is the documentation on

<taskdef name="schemaexport"
<path refid="xdoclet.classpath"/>
<path refid="hibernate.classpath"/>
When I google for schemaexport, all I can find is javadoc documentation. Is there a tutorial on this subject somewhere? I would love to know what database vendors are supported.
Posts: 11962
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the SchemaExport task supports the very same vendors that Hibernate supports in general (which is like almost every database vendor in existence today...)
Siegfried Heintze
Ranch Hand
Posts: 420
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I spent many hours discovering that I must have my schemaexport target depend on my "dist" target. Why is this?

(1) I thought schemaexport would have to have access to the hbm.xml files, but instead it has access to the compile class files originally in the bin directory. Does it not need access to the hbm.xml files I had hibernatedoclet create?

(2) Why does it need my pojos in a jar file in the path?

Below is my build.xml file that works for a trival class. I don't know why it works, however.

<?xml version="1.0" encoding="UTF-8"?>

<project name="Blog" default="generate-hibernate" basedir=".">
<property name="xdoclet.lib.dir" value="C:\Documents and Settings\Siegfried\My Documents\dev\XDoclet\xdoclet-1.2.3\lib" />
<property name="hibernate" location="C:/Documents and Settings/Siegfried/My Documents/dev/hibernate/hibernate-3.0" />
<property name="lib.dir" value="C:\Documents and Settings\Siegfried\My Documents\dev\hibernate\hibernate-3.0" />
<property name="hibernate.dir" value="src" />
<property name="src.dir" value="src" />
<property name="lib" location="lib" />
<property name="bin" location="bin" />
<property name="merge.dir" value="merge" />
<property name="jdbc" location="C:\Documents and Settings\Siegfried\My Documents\dev\jdbc-mssql-jtds\1.1\jtds-1.1.jar" />

<property name="name" value="casestudy"/>

<path id="classpath.base">
<pathelement location="${bin}" />
<pathelement location="${hibernate}/hibernate3.jar" />
<fileset dir="${hibernate}/lib" includes="**/*.jar" />
<pathelement location="${jdbc}" />
<pathelement location="C:/WinOOP/PureGamesInc/eclipse/PureGamesInc/lib/commons-lang-2.1/commons-lang-2.1.jar"/>

<path id="classpath.run">
<path refid="classpath.base" />
<pathelement location="${jdbc}"/>
<pathelement location="${lib}/${name}.jar"/>

<path id="xdoclet.lib.path">
<fileset dir="${xdoclet.lib.dir}">
<include name="*.jar"/>
<fileset dir="${lib.dir}">
<include name="*.jar"/>

<target name="generate-hibernate">
<taskdef name="hibernatedoclet"
classpathref="xdoclet.lib.path" />

<!-- Generate Hibernate mapping files -->
<hibernatedoclet destdir="${hibernate.dir}"
<fileset dir="${src.dir}">
<include name="**/*.java" />

<hibernate version="2.0" />

<target name="init">
<mkdir dir="${bin}" />
<mkdir dir="${lib}" />

<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${bin}">
<classpath refid="classpath.base" />
<copy todir="${bin}">
<fileset dir="${src.dir}">
<include name="**/*.properties" />
<include name="**/*.xml" />

<target name="clean">
<delete dir="${bin}" />
<delete dir="${lib}" />
<fileset dir="." includes="${name}db.*"/>
<delete file="${name}.sql"/>

<target name="dist" depends="compile">
<jar destfile="${lib}/${name}.jar" basedir="${bin}" />

<target name="schemaexport" depends="dist">
<java classname="org.hibernate.tool.hbm2ddl.SchemaExport" classpathref="classpath.run">
<arg line="--config=hibernate.cfg.xml --output=${name}.sql"/>

Ranch Hand
Posts: 62
Java Ruby Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found out that for SchemaExportTask you need your classpath defined as follows:

Additional work to do:
Copy your hibernate.properties file to build.classes.dir
Copy your **/*.hbm.xml files from src.dir to build.classes.dir

The compile target depends on init:

and schema depends on compile:

Hope this answered your question.
This parrot is no more. It has ceased to be. Now it's a tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!