-
Notifications
You must be signed in to change notification settings - Fork 233
Object to NoSQl Data mapping
chhavigangwal edited this page Nov 5, 2013
·
32 revisions
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.
Kundera maps data in cassandra or any other datastore seamlessly.
Entity to Table Mapping : Each table has an equivalent entity. Columns map to the attributes. 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;
@Column(name="city")
private String city;
}
Relation Mapping in Kundera and Cassandra :
@Entity
public class EmployeeInfo
{
@Id
@Column(name = "UserID")
@TableGenerator(name = "id_gen", allocationSize = 1, initialValue = 1)
@GeneratedValue(generator = "id_gen", strategy = GenerationType.TABLE)
private Long userid;
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@JoinColumn(name = "address_id")
private EmployeeAddress address;
Cassandra Equivalent :
CREATE TABLE "EmployeeInfo" (
key bigint PRIMARY KEY,
address_id bigint
) WITH COMPACT STORAGE AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
CREATE INDEX EmployeeInfo_address_id_idx ON "EmployeeInfo" (address_id);
@Entity
public class EmployeeAddress
{
@Id
@Column(name = "RegionID")
@TableGenerator(name = "id_gen", allocationSize = 1, initialValue = 1)
@GeneratedValue(generator = "id_gen", strategy = GenerationType.TABLE)
private Long address;
@Column(name="street")
private String street;
Cassandra Equivalent :
CREATE TABLE "EmployeeAddress" (
key bigint PRIMARY KEY,
street text
) WITH COMPACT STORAGE AND
bloom_filter_fp_chance=0.010000 AND
caching='KEYS_ONLY' AND
comment='' AND
dclocal_read_repair_chance=0.000000 AND
gc_grace_seconds=864000 AND
read_repair_chance=0.100000 AND
replicate_on_write='true' AND
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
Using Kundera :
EntityManager em = emf.createEntityManager();
EmployeeInfo emp_info = new EmployeeInfo();
EmployeeAddress address_info = new EmployeeAddress();
address_info.setStreet("street");
emp_info.setAddress(address_info);
em.persist(emp_info);
Stored In Cassandra :
select * from "EmployeeInfo";
key | address_id
-----+------------
1 | 1
select * from "EmployeeAddress";
key | street
-----+-----------
1 | newStreet
What goes behind?
-
Datastores Supported
- Releases
-
Architecture
-
Concepts
-
Getting Started in 5 minutes
-
Features
- Object Mapper
- Polyglot Persistence
- Queries Support
- JPQL (JPA Query Language)
- Native Queries
- Batch insert update
- Schema Generation
- Primary Key Auto generation
- Transaction Management
- REST Based Access
- Geospatial Persistence and Queries
- Graph Database Support
-
Composite Keys
-
No hard annotation for schema
-
Support for Mapped superclass
-
Object to NoSQL Data Mapping
-
Cassandra's User Defined Types and Indexes on Collections
-
Support for aggregation
- Scalar Queries over Cassandra
- Connection pooling using Kundera Cassandra
- Configuration
-
Kundera with Couchdb
-
Kundera with Elasticsearch
-
Kundera with HBase
-
Kundera with Kudu
-
Kundera with RethinkDB
-
Kundera with MongoDB
-
Kundera with OracleNoSQL
-
Kundera with Redis
-
Kundera with Spark
-
Extend Kundera
- Sample Codes and Examples
-
Blogs and Articles
-
Tutorials
* Kundera with Openshift
* Kundera with Play Framework
* Kundera with GWT
* Kundera with JBoss
* Kundera with Spring
-
Performance
-
Troubleshooting
-
FAQ
- Production deployments
- Feedback