Skip to content

Object to NoSQl Data mapping

chhavigangwal edited this page Nov 6, 2013 · 32 revisions

Data Storage in different datastores :

Different NoSQL datastores have different ways of storing data which may be in form of key-value pairs, columnfamilies, document objects or graphs. The main purpose of storing data in any of these datastores is to achieve simplicity in design, better performance and scalability. But in order to manipulate data stored in "NoSQL" fashion and leverage its benefits there has to be a solution which allows you to interact with that data in familiar way as was done with traditional databases. Kundera enables you to play with data stored in NoSQL databases in same old way by using specifications of JPA and thus enabling you to use the features of these datastores with minimal learning.

Objects in Kundera :

Kundera is a ORM tool for NoSQL databases. It is a JPA compliant object mapping solution for several NoSQL databases. Objects in Kundera are maintained in form of Entities and are recognized via JPA annotations.

Cassandra :

How Kundera Maps objects with data in Cassandra ?

Kundera maps data in cassandra or any other datastore seamlessly.

Entity to Table Mapping :

Each table has an equivalent entity and each column maps to an attribute of an entity. e.g.

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
public class User 
{
    @Id
    private String userId;
    
    @Column(name="first_name")
    private String firstName;
    
    @Column(name="last_name")
    private String lastName;
    
   
}

Equivalent in Cassandra :

CREATE TABLE "User" (
  key text PRIMARY KEY,
  first_name text,
  last_name text
) ;

Kundera facilitates using some of the key features of Cassandra with utmost ease. A brief explanation for the same can be found at the respective links below.

Under the hood

When you call persist on an object :

em.persist(object);

For further details on the mechanism of how Kundera persist an object please refer to details here.

Clone this wiki locally