File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes not persisting in HSQLDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "not persisting in HSQLDB" Watch "not persisting in HSQLDB" New topic
Author

not persisting in HSQLDB

Rich Morrison
Greenhorn

Joined: Aug 27, 2004
Posts: 7
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

Joined: Feb 05, 2001
Posts: 17249
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
pascal betz
Ranch Hand

Joined: Jun 19, 2001
Posts: 547
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

Joined: Aug 27, 2004
Posts: 7
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

Joined: Apr 04, 2004
Posts: 252
comment this out or use validate instead of create



Thanks,
Santosh
Mykola Makhin
Greenhorn

Joined: Feb 05, 2010
Posts: 7
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

Joined: Feb 05, 2010
Posts: 7
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

Joined: Feb 05, 2010
Posts: 7
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
 
subject: not persisting in HSQLDB
 
Similar Threads
Weird Exception
Cannot insert record into Database!
Hibernate Exception: Could not insert and JDBC Rollback failed..
Copy Data From One Database to other using hibernate ?
StaleStateException