-->
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.  [ 3 posts ] 
Author Message
 Post subject: build successful, but no tables show up
PostPosted: Thu Jun 23, 2005 1:05 pm 
Newbie

Joined: Thu Jun 23, 2005 12:25 pm
Posts: 7
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

I am trying to run an example from the Hibernate Developer's Notebook. I can run the code below and type in ant schema. It looks like it's running fine, until I run ant db again and there are no tables and there is also no code in the .sql file it's created. Can anyone help me get past this error?

Thanks in advance,

Hibernate version:
2.1.7c since that was recommended by the book

Build document:
<?xml version ="1.0"?>
<project name="Harnessing Hibernate: The Developer's Notebook" default="db" basedir=".">
<!--Set up properties containing important project directories-->
<property name = "source.root" value="src"/>
<property name = "class.root" value="classes"/>
<property name = "lib.dir" value="lib"/>
<property name = "data.dir" value="data"/>

<!--Set up the class path for compilation and execution-->
<path id="project.class.path">
<!--Include our own classes, of course-->
<pathelement location="${class.root}"/>
<!--Include jars in the project library directory-->
<fileset dir="${lib.dir}">
<include name="*.jar"/>
</fileset>
</path>

<target name="db" description="Runs HSWLDB database management UI against the db file--use when application is not running">
<java classname="org.hsqldb.util.DatabaseManager" fork="yes">
<classpath refid="project.class.path"/>
<arg value="-driver"/>
<arg value="org.hsqldb.jdbcDriver"/>
<arg value="-url"/>
<arg value="jdbc:hsqldb:${data.dir}/music"/>
<arg value="-user"/>
<arg value="sa"/>
</java>
</target>
<!--Teach ant how to use Hibernate's code generation tool-->
<taskdef name="hbm2java" classname="net.sf.hibernate.tool.hbm2java.Hbm2JavaTask" classpathref="project.class.path"/>

<!-- Generate the java code for all mapping files in our source tree -->
<target name="codegen" depends="prepare" description="Generate Java source from the O/R mapping files">
<hbm2java output="${source.root}">
<fileset dir="${source.root}">
<include name="**/*.hbm.xml"/>
</fileset>
</hbm2java>
</target>

<!--Create our runtime subdirectories and copy resources into them-->
<target name="prepare" description="Sets up build structures">
<mkdir dir="${class.root}"/>

<!--Copy our property files and O/R mappings for use at runtime-->
<copy todir="${class.root}">
<fileset dir="${source.root}">
<include name="**/*.properties"/>
<include name="**/*.hbm.xml"/>
</fileset>
</copy>
</target>

<!--Compile the java source of the project-->
<target name="compile" depends="prepare" description="Compiles all java classes">
<javac srcdir="${source.root}" destdir="${class.root}" debug="on" optimize="off" deprecation="on">
<classpath refid="project.class.path"/>
</javac>
</target>

<!--Generate the schemas for all mapping files in our class tree-->
<target name="schema" depends="compile" description="Generate DB schema from the O/R mapping files">
<!--Teach Ant how to use Hibernate's schema generation tool-->
<taskdef name="schemaexport" classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask" classpathref="project.class.path"/>
<schemaexport properties="${class.root}/hibernate.properties" output="schema.sql" quiet="false" text="yes" drop="yes" delimiter=";">
<fileset dir="${class.root}">
<include name="**.*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
</project>


Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<class name="com.oreilly.hh.Track" table="Track">
<meta attribute="class-description">
Represents a single playable track in the music database.
@author Jim Elliott (with help from Hibernate)
</meta>

<id name="id" type="int" column="TRACK_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</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 the track was created</meta>
</property>

<property name="volume" type="short">
<meta attribute="field-description">How loud to play the track</meta>
</property>

</class>
</hibernate-mapping>


hibernate.properties file:
hibernate.dialect=net.sf.hibernate.dialect.HSQLDialect
hibernate.connection.driver_class=org.hsqldb.jdbcDriver
hibernate.connection.url=jdbc:hsqldb:data/music
hibernate.connection.username=sa
hibernate.connection.password=


Full stack trace of any exception that occurs:
R:\soa\bin\Hibernate2.1.7\hibernate-2.1.7c\hibernate-2.1\Project>ant schema
Buildfile: build.xml

prepare:

compile:

schema:
[schemaexport] 10:51:54,027 INFO Environment:478 - Hibernate 2.1.7
[schemaexport] 10:51:54,230 INFO Environment:512 - loaded properties from resou
rce hibernate.properties: {hibernate.connection.username=sa, hibernate.connectio
n.password=, hibernate.cglib.use_reflection_optimizer=true, hibernate.dialect=ne
t.sf.hibernate.dialect.HSQLDialect, hibernate.connection.url=jdbc:hsqldb:data/mu
sic, hibernate.connection.driver_class=org.hsqldb.jdbcDriver}
[schemaexport] 10:51:54,293 INFO Environment:538 - using CGLIB reflection optim
izer
[schemaexport] 10:51:54,293 INFO Environment:567 - using JDK 1.4 java.sql.Times
tamp handling
[schemaexport] 10:51:55,996 INFO Dialect:86 - Using dialect: net.sf.hibernate.d
ialect.HSQLDialect
[schemaexport] 10:51:58,261 INFO Configuration:632 - processing one-to-many ass
ociation mappings
[schemaexport] 10:51:58,277 INFO Configuration:641 - processing one-to-one asso
ciation property references
[schemaexport] 10:51:58,277 INFO Configuration:666 - processing foreign key con
straints
[schemaexport] 10:51:58,277 INFO Configuration:632 - processing one-to-many ass
ociation mappings
[schemaexport] 10:51:58,277 INFO Configuration:641 - processing one-to-one asso
ciation property references
[schemaexport] 10:51:58,277 INFO Configuration:666 - processing foreign key con
straints
[schemaexport] 10:51:58,293 INFO SchemaExport:98 - Running hbm2ddl schema expor
t
[schemaexport] 10:51:58,293 INFO SchemaExport:112 - writing generated schema to
file: schema.sql
[schemaexport] 10:51:58,293 INFO SchemaExport:160 - schema export complete

BUILD SUCCESSFUL
Total time: 14 seconds

Name and version of the database you are using:
HSQLDB 1.7.1

The generated SQL (show_sql=true): .
It's not generating SQL in the .sql file it's creating or showing up on the console

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 03, 2005 2:58 pm 
Newbie

Joined: Wed Nov 19, 2003 3:00 am
Posts: 7
Location: Madison, Wisconsin, USA
Strange, this is the first report I've seen of this problem with respect to Hypersonic 1.7.1. I know there was a change in Hypersonic's behavior starting with version 1.7.2. In a nutshell, old versions would automatically shut down the database as soon as there were no more connections to it. The new versions don't shut down unless given an explicit shutdown command, and hbm2ddl does not issue that shutdown command, so Hypersonic never flushes the changes to disk before the JVM gets shut down. Hence, your schema is never written to disk.

If you were using Hypersonic 1.8 or later you could work around this by requesting the old automatic shutdown behavior. Hibernate will enable this if you define hibernate.connection.shutdown=true in your properties or XML file.

I don't know if it will help you, but you could try updating to a recent Hypersonic release and defining this property.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 6:51 pm 
Newbie

Joined: Thu Aug 11, 2005 12:02 am
Posts: 6
Thanks a lot, branchboy.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.