here is my build file:
*******************build.xml *********************************
<?xml version="1.0"?>
<!-- ======================================================================
Feb 7, 2006 10:55:59 PM
HibernateDeveloper
description
ongxa888
====================================================================== -->
<project name="HibernateDeveloper" default="db" basedir=".">
<property name="src.dir" location="src" />
<property name="build.dir" location="build" />
<property name="build.classes.dir" location="${build.dir}/classes" />
<property name="build.data.dir" location="${build.dir}/data" />
<property name="lib.dir" location="lib" />
<property name="dist" location="dist" />
<property name="hibernate.tool.dir" value="D:\HibernateTool\plugins\org.hibernate.eclipse_3.1.0.beta4\lib\tools" />
<property name="hibernate.dir" value="E:\OpenSourceLibrary\hibernate-3.1" />
<property name="hibernate.lib.dir" value="E:\OpenSourceLibrary\hibernate-3.1\lib" />
<property name="mysql.driver.dir" value="E:\OpenSourceLibrary\mysql-connector-java-3.1.10" />
<property name="hsqldb.lib.dir" value="E:\OpenSourceLibrary\hsqldb\lib" />
<property name="log4j.file" value="E:\OpenSourceLibrary\hibernate-3.1\etc\log4j.properties"/>
<!-- Define paths -->
<path id="hibernate.tool.classpath">
<fileset dir="${hibernate.tool.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="hibernate.classpath">
<fileset dir="${hibernate.dir}">
<include name="hibernate3.jar" />
</fileset>
</path>
<path id="hibernate.lib.classpath">
<fileset dir="${hibernate.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="mysql.driver.classpath">
<fileset dir="${mysql.driver.dir}">
<!-- include *bin.jar for window , *bin-g.jar for linux -->
<include name="mysql-connector-java-3.1.10-bin.jar" />
</fileset>
</path>
<path id="hsqldb.lib.classpath">
<fileset dir="${hsqldb.lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<path id="project.classpath">
<path refid="hibernate.classpath" />
<path refid="hibernate.lib.classpath" />
<path refid="hibernate.tool.classpath" />
<path refid="mysql.driver.classpath" />
<path refid="hsqldb.lib.classpath" />
<path location="${build.classes.dir}"/>
</path>
<target name="init" description="create folder structure">
<mkdir dir="${src.dir}" />
<mkdir dir="${build.dir}" />
<mkdir dir="${build.classes.dir}" />
<mkdir dir="${build.data.dir}" />
<mkdir dir="${lib.dir}" />
<mkdir dir="${dist}" />
<copy file="${log4j.file}" todir="${src.dir}"/>
</target>
<target name="db" description="Runs HSQLDB UI against the
database file - use when application is not running">
<java classname="org.hsqldb.util.DatabaseManager" fork="true">
<classpath refid="project.classpath">
</classpath>
<arg value="-driver" />
<arg value="org.hsqldb.jdbcDriver" />
<arg value="-url" />
<arg value="jdbc:hsqldb:file:${build.data.dir}/canhac" />
<arg value="-user" />
<arg value="sa" />
</java>
</target>
<!--Teach Ant how to use Hibernate's code generation tool-->
<taskdef name="hibernatetool" classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath" />
<!-- Generate the java code for all mapping files in src tree
-->
<target name="codegen" depends="init" description="Generate Java source from the O/R mapping files">
<hibernatetool destdir="${src.dir}">
<classpath refid="project.classpath">
</classpath>
<configuration>
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml" />
</fileset>
</configuration>
<hbm2java destdir="${src.dir}" />
</hibernatetool>
</target>
<target name="compile" depends="init" description="Compile all Java classes">
<javac srcdir="${src.dir}" destdir="${build.classes.dir}" debug="on" optimize="off" deprecation="on">
<classpath refid="project.classpath" />
</javac>
</target>
<target name="HSQLDB-schema" depends="compile" description="Generate DB schema from O/R mapping file">
<hibernatetool destdir="${src.dir}">
<classpath refid="project.classpath">
</classpath>
<configuration configurationfile="hibernate.cfg.xml">
</configuration>
<hbm2ddl create="true" />
</hibernatetool>
</target>
<target name="MySQL-schema" depends="compile" description="Generate DB schema from O/R mapping file">
<hibernatetool destdir="${src.dir}">
<classpath refid="project.classpath">
</classpath>
<configuration configurationfile="mysql-hibernate.cfg.xml">
</configuration>
<hbm2ddl create="true" />
</hibernatetool>
</target>
<target name="CreateTest" depends="compile" description="Creates and persites some sample data">
<java classname="chapter2.CreateTest" fork="true">
<classpath refid="project.classpath">
</classpath>
</java>
</target>
<target name="clean" depends="init">
<delete dir="${build.dir}" />
<delete dir="${dist}" />
<delete dir="${lib.dir}">
</delete>
</target>
</project>
************************************************************
i create a file call Track.hbm.xml ,and i use hibernate-tool to generate file .java and create shema. target "MySQL-schema" run ok, and it really create a table TRACK in my database , but , target "HSQLDB-schema" build successful ,i can see the sql statement ,but when i run target "db" to see hsqldb databse , no table is create . i don't know what's wrong , please help me. i searched . but no result
Thank you very much!
|