OpenCabinet aims to provide tools for making it easy and efficient to store all of an application's data and other resources in a relational database, including the application code, libraries and configuration.
AccessDataSourceByPrimaryKey ds = new AccessDataSourceByPrimaryKey(dataSource); Object[] row = ds.selectRow(tableName, primaryKeyValue); String column = ds.selectString(tableName, columnName, primaryKeyValue); ds.commit( Insert(tableName, column1, column2, column3, column4) .delete(tableName, primaryKeyValue) .update(tableName, column1, column2, column3, KEEP));
No need to write SQL, no need to write JDBC boilerplate code, no need for any setup or configuration files (table column and primary key definitions are extracted from the database itself).
Storing large objects in a relation database requires special consideration, and many projects continue to store their data in two places, with the bigger chunks on the file system and only smaller pieces and the file's meta data in the database. This results in extra complexities in maintaining the system as a whole (for example backup operations or setting up a network file system). OpenCabinet includes a storage schema for binary files and large text data that puts all the data right in the database, with redundant replication to local disks to reduce the strain on the database and increase performance. This system is optimized for efficiently storing repeated or similiar pieces of data (as are often found in systems that maintain a revision history), using shared pointers, compression and differential storage.
Another thing that is less than straight-forward is how to store complex data types and collections (such as lists or maps) in a relational database. OpenCabinet offers a number of data types to address this issue. Simply speaking, the complex data type gets serialized into a number of internal database tables and OpenCabinet gives you an integer id for it that can be used to retrieve it later.
Building on the Changeset API to update database rows by primary key, OpenCabinet features revision history for your database tables. This is implemented using mirror (history) tables, that keep track of all previous versions of the database. The update timeline is organized around revision numbers, similar to Subversion, and changesets can be annotated with comments and assigned to the subsystems and end-users that performed these changes.
As much as we would have liked to use a couple of popular helper libraries, in order to ease installation, OpenCabinet uses only the libraries provided by the Java 5 Standard Edition, and has no additional dependencies except for the JDBC drivers for the database of your choice.