Over a million developers have joined DZone.

JPA Layer Over Kudu Using Kundera (Part 2)

DZone's Guide to

JPA Layer Over Kudu Using Kundera (Part 2)

Learn about the new features of Kundera with Kudu, such as support for embedded entities, secondary indexes, and positional and parameterized queries.

· Database Zone ·
Free Resource

Download the Altoros NoSQL Performance Benchmark 2018. Compare top NoSQL solutions – Couchbase Server v5.5, MongoDB v3.6, and DataStax Enterprise v6 (Cassandra).

Before getting started, be sure to check out Part 1

New Features of Kundera-Kudu

These features are available from Kundera 3.9 onwards.

Embedded Entities Are Supported

Embedded entities are stored in parallel to columns (similar to RDBMS).


@Table(name = "PERSON_EMBED_KUDU", schema = "keyspace-Name@pu-name")
public class EmbeddablePerson {
 private String personId;

 private String personName;

 private Address address;


Embedded entity:

public class Address {
 private String street;

 private String city;

 private String country;

For more details, refer to this GitHub page on embeddables support in Kudu.

Primary Key Auto Generation

Currently, GenerationType.AUTO is supported.

@Table(name = "USER", schema = "keyspace-Name@pu-name")
public class User {
 @GeneratedValue(strategy = GenerationType.AUTO)
 private String id;

 private String name;

 // getter and setter

The id attribute in the entity must be of String type.

Secondary Indexes Using Elasticsearch

Elasticsearch can be used to store indexes of Kudu to perform faster aggregations. Refer to this GitHub page on Elasticsearch as an Index store for more details.

Positional and Parameterized Query Support

Sample queries:

  Query query = em.createQuery("Select p.age, p.salary from Person p where p.age >= ?1 and p.age <= ?2");
  query.setParameter(1, 20);
  query.setParameter(2, 40);
  List < Person > results = query.getResultList();

  Query query = em.createQuery("Select p.age, p.salary from Person p where p.age >= :age1 and p.age <= :age2");
  query.setParameter("age1", 20);
  query.setParameter("age2", 40);
  List < Person > results = query.getResultList();


Kundera, being JPA compliant, makes it easier to work with NoSQL databases. Regardless of the database used, the user needs to write the same JPA query. Also, if a user wants to switch databases (say from HBase to Kudu), there is no need to rewrite the code — just change some configurations in the persistence.xml file.

Download the whitepaper, Moving From Relational to NoSQL: How to Get Started. We’ll take you step by step through your first NoSQL project.

kundera ,kudu ,database ,jpa

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}