Sorry to ask such a basic question, but after all the manuals and the list archives for "cache" and googling for "derby write cache", I'm still stumped.

I've written a simple web application wherein users take a survey and the results are saved to a database, using the Persistence API. It runs in Sun's Java Application Server, using TopLink Essentials as the Persistence provider and Derby as the database, all running on a Fedora Core 3 system. The application runs and data does indeed get written to the Derby database, but not for a while, generally several transactions later. Obviously, the data is being cached, which is generally a good thing. However, when a power outage occurs, there's no time for the cache to be written to the database. Transactions that happened two weeks earlier were not written to the database, and we lost data, which seems silly under the circumstances. The server is very lightly loaded -- there's only a few transactions each week.

So, I need to make sure the cache is written to disk within a reasonable length of time. How can I either
1) force data to be written to disk after every transaction
or
2) force data to be written to disk within some fixed time?

I asked about this on the TopLink mailing list, and was told TopLink doesn't cache writes.

The only thing about write caching I found in the Derby manuals was:
SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE system procedure
but this must be called using the JDBC API:
CallableStatement cs = conn.prepareCall ("CALL SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()");
cs.execute();
but I don't think I have access to the connection variable when using JPA.

(I did find out about the on-disk write cache, but that isn't enabled on the drive.)


Here's my persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/ persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http:// java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="OMSI-EE5cPersistenceUnit" transaction- type="JTA"> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvide r</provider>
<jta-data-source>jdbc/omsiDatasource</jta-data-source>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>



Reply via email to