Introduction
A SpringBoot JPA specification is used to manage relational data in Java applications. It enables data access and persistence across a Java object or class and a relational database. Object-Relation Mapping (ORM) is used by JPA (ORM). It's a collection of interfaces. It additionally offers a runtime EntityManager API for executing queries and transactions on the objects against the database. It employs the object-oriented query language JPQL, which is platform neutral (Java Persistent Query Language). A framework is not JPA. Any framework can use it to implement the idea it describes.
UserResource to use JPA - Updating POST and DELETE methods

This part will convert the deleteUser() method and the createUser() method to JPA. Let's update UserJPAResource.java with the necessary adjustments.
Step 1: Modify
Modify the service provided by the deleteUser() function.
Step 2: Delete
UserRepository's delete() method does not return anything. Delete the return type.
@DeleteMapping("/jpa/users/{id}")
public void deleteUser(@PathVariable int id)
{
userRepository.deleteById(id);
}
It throws an exception if it is unsuccessful.
Step 3: Postman Application
Send a DELETE request using the Postman application and the URL http://localhost:8080/jpa/users/1 .

Status: 200 OK denotes that the record has been deleted successfully.
The URL http://localhost:8080/jpa/users/1 should be used to make another DELETE request. "No entity with id 1 exists" is the message returned.
{
"timesatmp": "2022-09-27T13:35:02",
"message": "No class com.javatpoint.rest.webServices.restfulwebservices.user. User entity with id 1 exists! ",
"details": "uri=/jpa/user/1"
}
To create a user, we shall right away issue a POST request.
Step 4: POST Request
Send a POST request to http://localhost:8080/jpa/users using the specified URL.
Step 5: Selection
Make sure that application/json is selected for the Content Type when you click the Headers tab.

Step 6: Input
The user's name and Date Of Birth should be entered in the Body tab. The name Ravi has been input.

Step 7: Exception
By pressing the Send button, the ConstaintViolationException is thrown when we attempt to create a user.
Hibernation employs a sequence due to which the user entity's Id is a created value. The id of the row that Hibernate is attempting to insert is 1. It is in contrast with the information we currently know.
Step 8: Resolution
In order to resolve the conflict, change the Ids in the data.sql file by opening it.
insert into user values(101, sysdate(), "Ravi");
insert into user values(102, sysdate(), "Abel");
insert into user values(104, sysdate(), "Tia");
Step 9: POST Request Again
Publish a POST request once again. It displays Status: 201 Created as a result. The status indicates successful user creation.





