wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

Where is documentation for ant task schemaexport

Siegfried Heintze
Ranch Hand

Joined: Aug 11, 2000
Posts: 381
Where is the documentation on

<taskdef name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask">
<classpath>
<path refid="xdoclet.classpath"/>
<path refid="hibernate.classpath"/>
</classpath>
</taskdef>
?
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
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
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: 381
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.
Thanks,
Siegfried

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

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

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

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

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

<hibernate version="2.0" />
</hibernatedoclet>
</target>

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

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

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

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

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

</project>
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 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.
Pierre


Pierre
 
 
subject: Where is documentation for ant task schemaexport
 
Similar Threads
Modifying appserver.home property in build.properties file NOT working
Problem in schema export - Hibernate
Solution to "log4j:WARN No appenders could be found for logger"
may be some bugs inside schemaexport ?
WAS 6.1 undeploy DefaultApplication