JPA Layer Over Kudu Using Kundera
JPA Layer Over Kudu Using Kundera
See how to set up and configure Kundera, an object mapper that supports a variety of databases and database tools.
Join the DZone community and get the full member experience.
Join For FreeRavenDB 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.
Kundera is a "Polyglot Object Mapper" with a JPA interface. Kundera currently supports Cassandra, MongoDB, HBase, Redis, OracleNoSQL, Neo4j, CouchDB, Kudu, Relational databases, and Apache Spark.
New folks should read Getting Started in 5 minutes.
Apache Kudu
Kudu is a columnar storage manager developed for the Hadoop platform. Kudu tables have a structured data model similar to tables in a traditional RDBMS.
Just like SQL, every table has a primary key made up of one or more columns. Rows can be efficiently read, updated, or deleted by their primary key. Kudu's simple data model makes it easy to port legacy applications. Tables are self-describing, so you can use standard tools like SQL engines (e.g. Drill) or Spark to analyze your data.
This new open source complement to HDFS and Apache HBase is designed to fill gaps in Hadoop's storage layer that have given rise to stitched-together, hybrid architectures.
JPA Over Kudu
Kudu is a new addition (in 3.4) to Kundera family. Kundera maps JPA Entity with Kudu Table.
How to Use
To use it, user needs to add the following dependency in pom.xml:
<dependency>
<groupId>com.impetus.kundera.client</groupId>
<artifactId>kundera-kudu</artifactId>
<version>${kundera.version}</version>
</dependency>
Check out the latest Kundera version here.
Persistence Unit Configuration
<persistence-unit name="kudu_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="quickstart.cloudera" />
<property name="kundera.port" value="7051" />
<property name="kundera.keyspace" value="kudutest" />
<property name="kundera.client" value="kudu" />
<property name="kundera.ddl.auto.prepare" value="create" />
<property name="kundera.client.lookup.class" value="com.impetus.client.kudu.KuduDBClientFactory" />
</properties>
</persistence-unit>
Features
CRUD
Users can Create, Read, Update, and Delete data in Kudu Table using Kundera. Refer to the test-case for details.
Query
Users can perform basic SELECT
queries with WHERE
clause. Refer to the test-case for details.
Schema Generation
Users can automatically generate schema using kundera.ddl.auto.prepare
property in Persistence Unit.
Check Kundera documentation for more details about Kundera with Kudu.
Conclusion
Kundera, being JPA compliant, makes it easier to work with NoSQL databases. Irrespective 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.
Opinions expressed by DZone contributors are their own.
{{ parent.title || parent.header.title}}
{{ parent.tldr }}
{{ parent.linkDescription }}
{{ parent.urlSource.name }}