Record Storage Service provides an easy way to store / access record objects. It does not persist any attachments included in the records, only the Id and the metadata. To persist attachments one has to use the Binary Storage.
/** * Load the record with the given Id. * @param id Id of the record * @return a Record object or null, if no record with the given Id exists * @throws RecordStorageException if any error occurs */ Record loadRecord(Id id) throws RecordStorageException; /** * Stores the given Record object. An existing Record with the same ID is overwritten by the given record. * @param record the Record object * @throws RecordStorageException if any error occurs */ void storeRecord(Record record) throws RecordStorageException; /** * Removes the record with the given Id. * @param id Id of the record * @throws RecordStorageException if any error occurs */ void removeRecord(Id id) throws RecordStorageException; /** * Checks if a Record with the given Id exists in the storeage. * @param id Id of the record * @return true if a record with the given Id exists, false otherwise * @throws RecordStorageException if any error occurs */ boolean existsRecord(Id id) throws RecordStorageException; /** * Loads all records of the given source. * @param source the name of the data source * @return an Iterator over the Record objects * @throws RecordStorageException if any error occurs */ Iterator<Record> loadRecords(String source) throws RecordStorageException;
It is possible to provide different implementations for the RecordStorage interface. Below is a list of the currently available implementations.
The default implementation uses eclipseLink JPA to store the records in an apache derby database. The data is stored in the table RECORDS:
|ID||VARCHAR||a hashed value of the Id object of the record|
|SOURCE||VARCHAR||the source attribute of the Id object|
|RECORD||BLOB||the serialized record object without attachments|
The only configuration needed is a typicall eclipseLink configuration property file. Therin you can specify settings for logging, database connection settings. For more information please refer to the eclipseLink documentation []. The configuration is located at configuration/org.eclipse.smila.recordstorage.impl/org.eclipse.smila.recordstorage.impl/persistence.properties.
# EclipseLink properties eclipselink.logging.level=INFO eclipselink.target-server=None eclipselink.target-database=org.eclipse.persistence.platform.database.DerbyPlatform eclipselink.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver eclipselink.jdbc.url=jdbc:derby:workspace/.metadata/.plugins/org.eclipse.smila.recordstorage.impl/recordstorage;create=true eclipselink.jdbc.password=smila eclipselink.jdbc.user=smila eclipselink.ddl-generation=create-tables
After starting Smila for the first time, the DDL generation setting will print out some nasty warnings, complaining that it can't create some tables. These warnings are not critical. You can get rid of them by setting eclipselink.ddl-generation=none, but only after Smila was started at least once (and the tables were created).
At the moment it is necessary to import all packages containing JDBCDriver classes in bundle org.eclipse.smila.recordstorage.impl. So for changing from derby to another database it is not sufficient to change the configuration in persistence.properties, you also have to add import package statementsv for the JDBC driver to use to your bundles manifest. This will hopefully be changed with the next release of eclipseLink.