-
Notifications
You must be signed in to change notification settings - Fork 0
Datastax java driver support for Cassandra using Kundera
When CQL was introduced initially, it used Thrift as a network transport which had its own set of limitations and in order to overcome these limitations a Cassandra specific binary protocol was introduced later.
With the introduction of the Cassandra's binary protocol and based on user requests :#385,#467,#544 ; its support has been enabled in Kundera from 2.11 release via datastax java driver. Datastax java driver is client driver for Apache Cassandra that enables using (CQL3) via Cassandra's binary protocol.
In order to use it via Kundera :
In order to use kundera-cassandra-ds-driver with maven based project, need to add:
<dependency>
<groupId>com.impetus.kundera.client</groupId>
<artifactId>kundera-cassandra-ds-driver</artifactId>
<version>2.11</version>
</dependency>
<persistence-unit name="ds_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9042" />
<property name="kundera.keyspace" value="KunderaExamples" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.ddl.auto.prepare" value="create" />
<property name="kundera.client.lookup.class"
value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
</properties>
</persistence-unit>
###Examples: CRUD :
- Select
Query findQuery = entityManager.createQuery("Select p from PersonCassandra p", PersonCassandra.class);
List<PersonCassandra> allPersons = findQuery.getResultList();
findQuery = entityManager.createQuery("Select p.age from PersonCassandra p where p.personName = vivek");
- Update
String updateQuery = "update PersonCassandra p set p.personName=''KK MISHRA'' where p.personId=1";
q = entityManager.createQuery(updateQuery);
q.executeUpdate();
- Delete
String deleteQuery = "DELETE from PersonCassandra";
q = entityManager.createQuery(deleteQuery);
External Properties Configuration : DS specific properties can be set externally via property map as well :
DSClientFactory ds = new DSClientFactory();
final String RRP = "com.datastax.driver.core.policies.RoundRobinPolicy";
final String ERP = "com.datastax.driver.core.policies.ExponentialReconnectionPolicy";
final String DCRP = "com.datastax.driver.core.policies.FallthroughRetryPolicy";
Properties connectionProperties = CassandraPropertyReader.csmd.getConnectionProperties();
...
KunderaMetadata kunderaMetadata = ((EntityManagerFactoryImpl) emf).getKunderaMetadataInstance();
...
ds.initialize(propertyMap);
Object conn = ds.createPoolOrConnection();
Cluster cluster = (Cluster) conn;
HostDistance distance = HostDistance.LOCAL;
Configuration configuration = cluster.getConfiguration();
Pagination : You can paginate the query results fetched from Cassandra using Datastax driver via ResultIterator :
String queryString= "Select t from Token t";
com.impetus.kundera.query.Query query = (com.impetus.kundera.query.Query) em.createQuery(queryString,
Token.class);
query.setFetchSize(fetchSize);
int count=0;
Iterator<Token> tokens = query.iterate();
while(tokens.hasNext())
{
...
}
Examples to refer :
- https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-cassandra/cassandra-ds-driver/src/test/java/com/impetus/kundera/client/cassandra/dsdriver/DSClientExternalPropertyTest.java
- https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-cassandra/cassandra-ds-driver/src/test/java/com/impetus/kundera/client/cassandra/crud/CriteriaQueryTest.java
- https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-cassandra/cassandra-ds-driver/src/test/java/com/impetus/kundera/client/cassandra/crud/ResultIteratorTest.java
- https://github.com/impetus-opensource/Kundera/blob/trunk/src/kundera-cassandra/cassandra-ds-driver/src/test/java/com/impetus/kundera/client/cassandra/crud/PersonEntityTest.java
-
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