longevity

A Persistence Framework for Scala and NoSQL

View project on GitHub

cassandra translation

Every Cassandra table has at least one column: A column named p, which stores the persistent object translated into JSON.

If the write timestamps configuration is turned on, then created_timestamp and modified_timestamp columns are added. If optimistic locking is turned on, then a row_version column is also added. The Cassandra optimistic locking implementation uses lightweight transactions for updates and deletes, introducing an IF row_version = ... clause to the database command. This will incur a performance penalty.

More columns are added to support any keys or indexes for the persistent type. Every property used in a key or index is expanded in to a sequence of property components that all have basic types. These property components are stored in Cassandra columns, and all have names prefixed with prop_. Those property components that do not belong to your primary key are indexed.

The property component columns are used to back calls to Repo.retrieve, as well as query retrievals. Please note that queries constructed using properties that are not part of a longevity key or index will fail.

Cassandra table names are generated by underscoring the camel-cased name of the persistent class.

prev: persistent to json
up: translating persistents to the database
next: cassandra keys