Database Reference
In-Depth Information
CRUD using Kundera
It is very easy to perform CRUD operations using Kundera. To perform CRUD
operations, we need to have an instance of EntityManager . Obtaining an
EntityManager instance consists of two steps. First, we need to obtain an instance
of EntityManagerFactory , and then, we can use this factory instance to get an
EntityManager instance. JPA requires the deinition of a persistence-unit in an
XML ile in order to create an EntityManagerFactory instance, as follows:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("hba
se_pu");
EntityManager em = emf.createEntityManager();
A sample persistence-unit is as follows:
<persistence-unit name="hbase_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="2181" />
<property name="kundera.keyspace" value="KunderaExample" />
<property name="kundera.dialect" value="hbase" />
<property name="kundera.client.lookup.class" value="com.impetus.
client.hbase.HBaseClientFactory" />
</properties>
</persistence-unit>
Now, let's take an example to explore the implementation of CRUD operations using
Kundera. An organization wants to maintain their employee records with some
attributes such as name, address, date of joining, and department. In order to map
the data columns, you need to create equivalent Java entity objects.
 
Search WWH ::




Custom Search