-->
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.  [ 5 posts ] 
Author Message
 Post subject: Help with Hibernate Tutorial
PostPosted: Wed Jul 20, 2005 12:04 pm 
Newbie

Joined: Wed Jul 20, 2005 11:44 am
Posts: 3
Hibernate version: 3.0

Name and version of the database you are using: hsqldb 1.8.0

I'm trying to complete the introduction to Hibernate tutorial and am having problems at section 2.2.6 Loading and storing objects. I am able to store objects successfully using the following in the hibernate properties file:
Code:
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

but when I comment out the hbm2ddl.auto property, I am no longer able to store or list objects (as suggested by the tutorial). I get an error that indicates the table is not in existence
Code:
[java] 11:24:59,167 ERROR JDBCExcetionReporter:72 – Table not found in statement [select max<EVENT_ID> from EVENTS]

Any help would be greatly appreciated!


Top
 Profile  
 
 Post subject: Re: Help with Hibernate Tutorial
PostPosted: Wed Jul 20, 2005 12:27 pm 
Newbie

Joined: Thu Jul 14, 2005 5:19 am
Posts: 7
Location: Munich, Germany
Steve.Hookway wrote:
Hibernate version: 3.0

Name and version of the database you are using: hsqldb 1.8.0

I get an error that indicates the table is not in existence
Code:
[java] 11:24:59,167 ERROR JDBCExcetionReporter:72 – Table not found in statement [select max<EVENT_ID> from EVENTS]

Any help would be greatly appreciated!


Well, this may sound stupid, but have you checked if the table DOES exist?
I don't know too much about HSQLDB, but I think it can also keep tables in memory without saving them to disk (temporary lookup tables for the application). When the process stops, the data (and the table!) is gone. That's ok / desired behavior in some cases.

I've never used HSQLDB myself because it's hard to see what's going on (how do you check the data in the table?). I recommend MySQL for development and testing. Setup is easy...

But anyway, if you don't want to do that (just yet):
* Check the HSQL docs for making tables persistent (save to a file)
* I think HSQL requires an explicit "shutdown" (close?) command to make sure that all data is written to disk. Do you use an explicit shutdown/close?

HTH,

Holger


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 12:44 pm 
Newbie

Joined: Wed Jul 20, 2005 11:44 am
Posts: 3
Thanks for the reply. I think I will try to configure hibernate with mysql. I was just trying to get the tutorial to work. I guess my question was less of a hibernate question and more of HSQLDB question. I'm pretty sure the table isn't there, but wasn't sure how to make it persist. As using
Code:
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

Will drop and recreate the table every time, and
Code:
<property name="hbm2ddl.auto">update</property>
doesn't seem to create a table if there is none in existence. I have tried using create for storing and then commenting out the hbm2ddl property all together for retrieving, but it seems the table doesn't persist across sessions.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 1:01 pm 
Newbie

Joined: Thu Jul 14, 2005 5:19 am
Posts: 7
Location: Munich, Germany
Steve.Hookway wrote:
Thanks for the reply. I think I will try to configure hibernate with mysql. I was just trying to get the tutorial to work. I guess my question was less of a hibernate question and more of HSQLDB question.


Yep. Maybe. Unfortunately, I know even less about HSQLDB than about Hibernate *g*

However, a quick search turned up this:
http://hsqldb.sourceforge.net/web/hsqlDocsFrame.html

and I'm guessing it's this section:
http://hsqldb.sourceforge.net/doc/guide ... tml#N101A8

So, for persisting the table, you need two things:
1) a database URL starting with "jdbc:hsqldb:file:" rather than "jdbc:hsqldb:mem:"

2a) an explicit SHUTDOWN command
or
2b) a connection property, shutdown=true
(section: "Closing the Database")

The documentation also says that this behavior has changed from HSQLDB 1.7.2 to 1.8.0. Maybe the Hibernate example wasn't updated for that (yet).

Well, I still prefer MySQL for development, but of course, I also like getting all my "tests" to work :-)

Good luck :-)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 20, 2005 1:42 pm 
Newbie

Joined: Wed Jul 20, 2005 11:44 am
Posts: 3
Wow Finch, you have been an excellent resource! Thanks for the help!


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