-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: why i can't create table with hsqldb ? Help me!
PostPosted: Mon Feb 13, 2006 12:37 pm 
Newbie

Joined: Mon Feb 13, 2006 12:30 pm
Posts: 12
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!


Top
 Profile  
 
 Post subject: oh .. i 'm sorry .... i forget posting Track.hbm.xml
PostPosted: Mon Feb 13, 2006 12:39 pm 
Newbie

Joined: Mon Feb 13, 2006 12:30 pm
Posts: 12
Here is it .

****************Track.hbm.xml ***************************
<?xml version="1.0" ?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="chapter2.Track" table="TRACK">
<meta attribute="class-description">
Represents a single playable track in the music database
</meta>
<id name="id" type="integer" column="Track_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"></generator>
</id>
<property name="title" type="string" not-null="true"/>
<property name="filePath" type="string" not-null="true" />
<property name="playTime" type="time">
<meta attribute="field-description">Playing Time
</meta>
</property>
<property name="added" type="date">
<meta attribute="field-description">When track is created.
</meta>
</property>
<property name="volume" type="short">
<meta attribute="field-description">How loud to play this
</meta>
</property>
</class>
</hibernate-mapping>
****************************************
Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 12:49 pm 
Newbie

Joined: Mon Feb 13, 2006 12:30 pm
Posts: 12
i use hibernate 3.1 and hsqldb 1.8 .


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 14, 2006 10:06 am 
Newbie

Joined: Mon Feb 13, 2006 12:30 pm
Posts: 12
hu hu hu .. . help me ! i lose 2 days for this . ... i'm a newbie .. ..help me for Valentine Day !!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.