• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

not persisting in HSQLDB

 
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have downloaded and run a few simple examples using:
Eclipse 3.2
Hibernate 3.1.3
HSQLDB 1.8
Windows XP

The examples work but nothing seems to be saved to disk.

Here is the config.xml
=======================


The code runs and I see "Grommets" from the select statement, but there is nothing saved to the table. If I open the table with HSQLBD console applet, the table is empty.

I tried turning off "hibernate.hbm2ddl.auto" and I tried ";shutdown=true" after the url, based on comments on other sites.

I have also tried creating the tables with HSQLDB before running tests. Same result.

I have edited the HSQLDB properties file and changed the default_table_type to "cached" with no change.

What am I doing wrong ???

TIA,
Rich Morrison
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, I didn't look at your mapping and code, it is late at night and I have to wake up early. But more as an FYI, Hypersonic is run in-memory, so when you shut down JBoss all the tables and data will be lost.

Mark
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey Mark

HSQLDB can also run in a "file" backed mode:

An In-Process Mode database is started from JDBC, with the database file path specified in the connection URL. For example, if the database name is testdb and its files are located in the same directory as where the command to run your application was issued, the following code is used for the connection:

Connection c = DriverManager.getConnection("jdbc:hsqldb:file:testdb", "sa", "");



see also the HSQLDB doc: http://www.hsqldb.org/web/hsqlDocsFrame.html

it seems the line

<property name="hibernate.connection.url">jdbc:hsqldb:file:c:\temp\productsDB\products_t</property>


indicates that he is using HSQLDB in file mode.

none of this explains why nothing ends up in the DB though ;-)
have you checked the file path ? perhaps try something without directories first ? have you turned on SQL logging in hibernate so you see what SQL statements are beeing sent to the DB ?

pascal
 
Rich Morrison
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark/Pascal,

Thanks for the replies.

Mark, I think that "memory" tables (from the HSQLDB preperties) are saved to disk. That's how I interpret the HSQLDB manual (page 6).

Pascal, yes I am using file mode in the connection. Could the path be wrong ? I think it could but I don't get any error in the log. I do have the show SQL option on and the generated SQL looks all right to me based on other examples I have seen in sample projects.

But maybe the path is wrong. I am not very familiar with "relative" path coding. In the Eclipse java project, the HSQLDB jar is included in the classpath as an external jar. The jar is in a folder in C:\Program Files\hsqldb. Is the path is relative to the location of hsqldb.jar ?

Still struggling,
Rich Morrison
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
comment this out or use validate instead of create

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having same problem. Did you find the solution?

P.S. Guys, do you even read?

Mark Spritzler wrote:But more as an FYI, Hypersonic is run in-memory, so when you shut down JBoss all the tables and data will be lost.


Rich Morrison wrote:jdbc:hsqldb:file:c:\temp\productsDB\products_t



Santosh Ramachandrula wrote:comment this out or use validate instead of create


Rich Morrison wrote:I tried turning off "hibernate.hbm2ddl.auto" and I tried ";shutdown=true" after the url, based on comments on other sites.




 
Mykola Makhin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.P.S. Some details:
Versions (from maven pom.xml):


Spring config (spring version is irrelevant I suppose):


The hibernate.cfg.xml:


The x.mvmn.blah.model.impl.BlahImpl:


Running code


With hibernate.hbm2ddl.auto set to create outputs this:
[Ljava.lang.Object;@12b27c38
[Ljava.lang.Object;@3f94a1f
[Ljava.lang.Object;@63713b42

With hibernate.hbm2ddl.auto set to validate, complains that table doesn't exist.
 
Mykola Makhin
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I've found the solution on StackOverflow: http://stackoverflow.com/questions/3551988/hsqldb-and-hibernate-jpa-not-persisting-to-disk

To make HSQL save data to disk immidiately I've added these properties to JDBC DB URL:
;shutdown=true;hsqldb.write_delay=false;

Seems to be working fine now.
reply
    Bookmark Topic Watch Topic
  • New Topic