Using Kundera with MongoDB: Creating a JPA Client Class

We have configured a JPA project for object/relational mapping to MongoDB database. Next, we shall run some CRUD operations using the JPA API. But, first we need to create a client class for the CRUD operations. We shall use a Java class as a client class.

  1. Select File ➤ New ➤ Other.
  2. In the New window, select Java ➤ Class and click on Next.
  3. In New Java Class wizard specify a Package (kundera) and a class Name (KunderaClient) as shown in Figure 9-14. Select the method stub for the main method to add to the class and click on Finish.

The kundera.KunderaClient class gets added to the KunderaMongoDB Maven project as shown in Figure 9-15.

We shall add the methods shown in Table 9-4 to the KunderaClient application to run CRUD operations on MongoDB. We shall invoke the methods from the main method and comment out all the methods to begin with. We shall uncomment one method at a time and run the KunderaClient application.

Source: Vohra Deepak (2015), Pro MongoDB™ Development, Apress; 1st ed. edition.

Leave a Reply

Your email address will not be published. Required fields are marked *