• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Where is documentation for ant task schemaexport

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
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>
 
Ranch Hand
Posts: 62
Ruby Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
Pierre
reply
    Bookmark Topic Watch Topic
  • New Topic