File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Ant, Maven and Other Build Tools and the fly likes Where is documentation for ant task schemaexport Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Where is documentation for ant task schemaexport" Watch "Where is documentation for ant task schemaexport" New topic

Where is documentation for ant task schemaexport

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 397
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.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
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...)

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 397
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="">
<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="">
<arg line="--config=hibernate.cfg.xml --output=${name}.sql"/>

Pierre Sugar
Ranch Hand

Joined: Dec 08, 2002
Posts: 62

I found out that for SchemaExportTask you need your classpath defined as follows:

Additional work to do:
Copy your 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.

I agree. Here's the link:
subject: Where is documentation for ant task schemaexport
It's not a secret anymore!