REST APIs and JPA

REST APIS

REST → Representational State Transfer

API → Application Programming Interfaces

Http Verb:

GET → To just get the data from a server and look at it

PUT → To modify the data

POST → To create new data

DELETE → To delete data

ORM

ORM → Object Relational Mapping, a technique used to map java objects to database tables.

JPA → Java Persistence API

A way to achieve ORM, includes interfaces and annotations that you use in your Java classes, requires a persistence provider (ORM tools) for implementation.

To use JPA, you need a persistence provider. A persistence provider is a specific implementation of the JPA specification. Examples of JPA presistence providers include Hibernate, EclipseLink and OpenJPA. These providers implement the JPA interfaces and provide the underlying functionality to interact with databases.

JPA is used only for relational databases and not for nosql databases

In the case of MongoDB, you don’t have a traditional JPA persistence provider. MongoDB is a NoSQL database, and Spring Data MongoDB serves as the “persistence provider” for MongoDB.

It provides the necessary abstractions and implementations to work with MongoDB in a Spring application.

Add this dependency to use it:

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-data-mongodb</artifactId>

</dependency>

Query Method DSL and Criteria API are two different ways to interact with a database when using Spring Data JPA for relational databases and Spring Data MongoDB for MongoDB databases.

Spring Data JPA is a part of the Spring Framework that simplifies data access in Java applications, while Spring Data MongoDB provides similar functionality for MongoDB.

0
Subscribe to my newsletter

Read articles from Nitish Srinivasa directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nitish Srinivasa
Nitish Srinivasa