-
Notifications
You must be signed in to change notification settings - Fork 0
Native CQL3 to object mapping
CQL (Cassandra Query language) is a standard way of manipulating data stored in Cassandra which is very much similar to SQL with some basic differences and constraints of a non relational and relational database.
With constant changes being made in Cassandra we are devising better and more optimum ways to facilitate leveraging its features in best possible manner using Kundera. However , you can query data objects in Cassandra using CQL3 native queries via Kundera.
Set CQL version 3:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu");
EntityManager em = emf.createEntityManager();
em.setProperty("cql.version", "3.0.0");
Relation Mapping in Kundera and Cassandra :
An Employee entity to be persisted in cassandra using Kundera
@Entity
public class EmployeeInfo
{
@Id
@Column(name = "UserID")
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
) ;
CREATE INDEX EmployeeInfo_address_id_idx ON "EmployeeInfo" (address_id);
Employee's address entity to be persisted in cassandra using Kundera
@Entity
public class EmployeeAddress
{
@Id
@Column(name = "key")
private Long address;
@Column(name="street")
private String street;
Cassandra Equivalent :
CREATE TABLE "EmployeeAddress" (
key bigint PRIMARY KEY,
street text
) ;
Persisting and querying the data 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);
final String noClause = "Select u from EmployeeInfo u";
Query q = em.createQuery(noClause);
List<EmployeeInfo> results = q.getResultList();
// With limit
q = em.createQuery(noClause);
q.setMaxResults(2);
results = q.getResultList();
Objects stored in Cassandra :
select * from "EmployeeInfo";
key | address_id
-----+------------
1 | 1
select * from "EmployeeAddress";
key | street
-----+-----------
1 | newStreet
-
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] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with--Couchdb)
- [Kundera with Elasticsearch] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Elasticsearch)
- [Kundera with HBase] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-HBase)
- [Kundera with Kudu] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Kudu)
- [Kundera with MongoDB] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-MongoDB)
- [Kundera with OracleNoSQL] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-OracleNoSQL)
- [Kundera with Redis] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-over-Redis)
- [Kundera with Spark] (https://github.com/impetus-opensource/Kundera/wiki/Kundera-with-Spark)
-
Extend Kundera
- Sample Codes and Examples
- [Blogs and Articles] (https://github.com/impetus-opensource/Kundera/wiki/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