O'Reilly logo

Apache Cassandra Essentials by Nitin Padalia

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mapping API

The Datastax Java driver provides a mapping API that helps to map our query results to Java classes. This API is provided as a separate artifact. We're using mapping API version 2.1.4 in our examples, below are dependency details:

// Maven Dependancy
<dependency>
   <groupId>com.datastax.cassandra</groupId>
   <artifactId>cassandra-driver-mapping</artifactId>
   <version>2.1.4</version>
</dependency>
// Gradle Dependancy
compile 'com.datastax.cassandra:Cassandra-driver-mapping:2.1.4'

The mapping API provides annotations to map a Java class to a Cassandra table. For example, our Status class can be mapped to Cassandra table status_updates_by_user, as in the following example of Status.java, updated as per the mapping API:

package cassandra.cassandraclient.model; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required