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

RavenDB vs MongoDB: Which is Better? This White Paper compares the two leading NoSQL Document Databases on 9 features to find out which is the best solution for your next project.  

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.

Get comfortable using NoSQL in a free, self-directed learning course provided by RavenDB. Learn to create fully-functional real-world programs on NoSQL Databases. Register today.

kundera ,kudu ,database ,jpa

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}