I'm currently trying to implement an in-memory database using Hibernate Annotations with HSQLDB and I'm running into a problem with Hibernate writing to disk.
Currently I have a small class setup to add a single item into the database. After the transaction, and even after a call for the session to flush to disk, the program exits and nothing gets written to disk. My .log and .script files are empty and show no records of my insert.
A funny thing I noticed is that if I put the thread to sleep... after about 10 seconds of waiting, my transaction is completed and flushed to disk.
I've looked through all the configuration setup properties and tried disabling all caches and any other properties that would prevent Hibernate and HSQLDB from writing to disk, but none of them have worked.
Has anyone run into this before, or have any idea why my flushes won't write to disk?
Here is a copy of my configuration class.....
Code:
AnnotationConfiguration config = new AnnotationConfiguration();
config.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
config.setProperty("hibernate.connection.driver_class", "org.hsqldb.jdbcDriver");
config.setProperty("hibernate.connection.url", "jdbc:hsqldb:file:db/db");
config.setProperty("hibernate.connection.username", "sa");
config.setProperty("hibernate.connection.password", "");
config.setProperty("hibernate.connection.pool_size", "1");
config.setProperty("hibernate.connection.autocommit", "true");
config.setProperty("hibernate.cache.provider_class", "org.hibernate.cache.HashtableCacheProvider");
config.setProperty("hibernate.hbm2ddl.auto", "update");
config.setProperty("hibernate.show_sql", "true");
config.setProperty("hibernate.transaction.factory_class", "org.hibernate.transaction.JDBCTransactionFactory");
config.setProperty("hibernate.current_session_context_class", "thread");
config.setProperty("hibernate.cache.use_second_level_cache","false");
// Add your mapped classes here:
config.addAnnotatedClass(DummyClass.class);
sessionFactory = config.buildSessionFactory();