At our recent developers conference in December in Munich we had a discussion about Transparent Persistence. We came up with a list of expectations:

  • Our four query interfaces (LINQ, Native Queries, Query-by-Example, SODA) must produce the same results.
  • db4o must produce the same results in client/server mode as it does in embedded mode.
  • When an object is explicitely stored with ObjectContainer#store(), modified uncommitted objects must be visible with their changed state for queries with the same transaction.
  • When Transparent Persistence is used, modified uncommitted objects must be visible with their changed state for queries with the same transaction.
  • Deleted objects must not be visible for queries with the same transaction.
  • Uncommitted changes must not be visible for other transactions.

Since we were not absolutely sure if we satisfy all these requirements, we wrote a couple of test cases. These tests can now be found in db4oj.tests in two versions of QueryConsistencyTestCase, one for our explicit #store() API, one for Transparent Persistence.

It turned out that we were getting unexpected results for two reasons:

  1. The server-side cache could keep objects in memory from previous query runs and these objects would not be refreshed automatically. The fix was straightforward: Whenever we store an object we now make sure it gets evicted from the server-side cache.
  2. In Transparent Persistence mode we used to do all the storing work on commit. This turned out to be too late. We fixed this by triggering Transparent Persistence storage before the execution of queries.

When we applied these 2 fixes, we also did some optimisations:
We now make sure that changed objects in client/server mode always get carried to the server in one single TCP message.

Fixes are available in the latest continous build and will be in the upcoming 7.8 development build.

Enjoy!