Hibernate.orgCommunity Documentation

Chapter 14. Cassandra

14.1. Configuring Cassandra
14.1.1. Adding Cassandra dependencies
14.1.2. Cassandra specific configuration properties
14.2. Storage principles
14.2.1. Properties and built-in types
14.3. Transactions and Concurrency

Cassandra is a distributed column family database.

This implementation uses CQL3 over the native wire protocol with java-driver. The currently supported version is Cassandra 2.1.

Note

Support for Cassandra is considered an EXPERIMENTAL feature as of this release.

Should you find any bugs or have feature requests for this dialect, then please open a ticket in the OGM issue tracker.

Configuring Hibernate OGM to use Cassandra is easy:

To get started quickly, pay attention to the following options:

And we should have you running. The following properties are available to configure Cassandra support:

Each Entity type maps to one Cassandra table. Each Entity instance maps to one CQL3 row of the table, each property of the Entity being one CQL3 column.

CQL3 table and column names are always quoted to preserve case consistency with the Java layer, with the table name matching the Entity class and the column names matching the Entity’s properties. The @Table and @Column annotations can be used to override identifier names in the usual manner.

Embedded objects are stored as additional columns in the owning Entitie’s table. The columns are named as EmbeddedTypeName.FieldOfEmbeddedType The type and field names can be overridden by annotations, but concatenation token delimiter cannot.

CQL3 types

CQL3 supports a smaller selection of numeric data types than Hibernate, so the missing types are autotmatically converted. byte and short values are promoted to integer.

CQL3 has no character type, so character is promoted to varchar i.e. String. Strings are UTF-8, not ascii.

CQL3 does not distinguish between byte[] and BLOB types for binary storage. These are handled equivalently.

CQL3 does not have a Calendar type, so these are converted to Dates, which are stores as time offset from the unix epoch.

Cassandra does not support transactions. Changes to a single Entity are atomic. Changes to more than one are neither atomic nor isolated.

Cassandra does not distinguish between update and insert operations and will not prevent creation of an Entity with duplicate Id, instead treating it as modification of the existing Entity.