-->
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.  [ 6 posts ] 
Author Message
 Post subject: Write delay with HSQLDB
PostPosted: Fri Oct 13, 2006 5:15 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
Hibernate version: 3.1.3
Name and version of the database you are using: HSQLDB 1.8.0

My problem is with HSQL DB, with memory or cached tables.
Simply, if i modify a value and then i close immediately my application (or i wait 1 second as example), the modifies are not stored in the database. If i modify a value and then i wait some seconds (as example 10 or more) before closing my applications, all modifies are persisted.
The problem is only with HSQLDB (with oracle i don't have this problem), and i think that depends of the parameter WRITE_DELAY, that i'm unable to configure in any way.
Any suggestions?
Thanks a lot :)

Config file HSQLDB section:
property name="dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:file:../db/filedb</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>
<property name="connection.shutdown">true</property>
<property name="connection.writedelay">0</property> // Not useful i think


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 9:31 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
The problem is that i don't close the SessionFactory before clising the program...

if (!HibernateUtil.getSessionFactory().isClosed()) HibernateUtil.getSessionFactory().close();


Top
 Profile  
 
 Post subject: Write delay with HSQLDB
PostPosted: Wed Apr 25, 2007 8:29 pm 
Newbie

Joined: Wed Apr 25, 2007 8:08 pm
Posts: 1
Hi Guidi,

Was the code closing the SessionFactory supposed to solve the write delay problem?

I am having the same difficulty with write delay in hsqldb, and I tried closing the SessionFactory before closing the program, and it had no effect.

Did you find any way to set the write delay to 0?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 3:51 am 
Newbie

Joined: Wed Jan 11, 2006 10:28 am
Posts: 19
Location: Fano, Italy
I0ve verified that closing sessions and session factory, all modifies are persisted in HSQLDB


Top
 Profile  
 
 Post subject: Re: Write delay with HSQLDB
PostPosted: Wed Aug 12, 2009 2:13 pm 
Newbie

Joined: Wed Aug 12, 2009 1:54 pm
Posts: 1
Solved - scroll down

Hi _Guidi and all,

it's obviously been a long time since the last post on that topic, hopefully so. can help. I' m running hibernate 3.3.2 with hsqldb v. 1.9 in standalone mode. Hibernate configured as follows.

Code:
<property name="hibernate.connection.url">jdbc:hsqldb:file:./db/default/;shutdown=true</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password"></property>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.writedelay">0</property>
    <property name="hibernate.connection.autocommit">false</property>
    <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>

    <property name="hibernate.hbm2ddl.auto">update</property>


Important for me is the hbm2ddl.auto set to update, since i wanna reuse existing databases. Referring to your post i closed my session and sessionfactory before terminating my app. During next run's startup, the following exception would appear:

Code:
java.sql.SQLException: error in script file line: 23 unexpected token: NOT required: :
   at org.hsqldb.jdbc.Util.sqlException(Util.java:365)
   at org.hsqldb.jdbc.Util.sqlException(Util.java:103)
   at org.hsqldb.jdbc.JDBCConnection.<init>(JDBCConnection.java:3236)
   at org.hsqldb.jdbc.JDBCDriver.getConnection(JDBCDriver.java:285)
   at org.hsqldb.jdbc.JDBCDriver.connect(JDBCDriver.java:245)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at java.sql.DriverManager.getConnection(Unknown Source)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
   at org.hibernate.cfg.Configuration.buildSettingsInternal(Configuration.java:2119)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2115)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1339)
   at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
   at de.laliluna.hibernate.SessionFactoryUtil.configureSession(SessionFactoryUtil.java:65)
   at de.laliluna.hibernate.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:26)
   at de.laliluna.example.TestExample.createHoney(TestExample.java:120)
   at de.laliluna.example.TestExample.main(TestExample.java:34)
Caused by: org.hsqldb.HsqlException: error in script file line: 23 unexpected token: NOT required: :
.
.
.


Don't think, the rest is important.
As i said, closing the session and -factory causes the problem. When not closing, changes won't be stored. I couldnt find any solution. Maybe, you already had similar problems.

Thanks. Regards,
luko

I finally solved that. It really f***** me up. Seems to be a problem with the rc of hsqldb 1.9. Didn't really notice i was using that. Switched to 1.8 stable now and it works just fine.
Cya


Top
 Profile  
 
 Post subject: Re: Write delay with HSQLDB
PostPosted: Wed Sep 09, 2009 12:03 pm 
Newbie

Joined: Fri Apr 21, 2006 6:33 am
Posts: 8
I am using Hibernate 3.3.2 GA and HSQLDB 1.8.0.10 and the property hibernate.connection.writedelay=0 (or 1 second) did not help me. If you open the script file you can see that the command 'SET WRITE_DELAY 10' is set as default. Changes are not make persistent if you close the database in less than 10 seconds after any change.

For my application I had to execute the following commands after openning the DB:

Code:
     Hibutil.beginTransaction();
     Session session = Hibutil.getSession();
   // make hsqldb to work as case-insensitive
   session.createSQLQuery("SET IGNORECASE TRUE").executeUpdate();
   // delay of 1 second to make changes persistent
   session.createSQLQuery("SET WRITE_DELAY 1").executeUpdate();
   Hibutil.commitTransaction();


*Note from Hibernate Manual: In general, when the system is very reliable, the setting can be left to the default. If it is not very reliable, or the data is critical a setting of 1 or 2 seconds would suffice. Only in the worst case scenario or with the most critical data should a setting of 0 or FALSE be specified as this will slow the engine down to the speed at which the file synch operation can be performed by the disk subsystem.

Values down to 10 millisconds can be specified by adding MILLIS to the command, but in practice a delay of 100 milliseconds provides 99.99999% reliability with an average one system crash per 6 days.


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