File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not persisting in HSQLDB

 
Rich Morrison
Greenhorn
Posts: 7
  • 1
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
pascal betz
Ranch Hand
Posts: 547
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Santosh Ramachandrula
Ranch Hand
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
comment this out or use validate instead of create

 
Mykola Makhin
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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: 7
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic