What You need
Java and OOP concepts (if not you can see my videos on java)
A favorite text editor or IDE : Intellj , Eclipse, VS code
Java 8 or later
Gradle 7.5+ or Maven 3.5+
Postman
Overview:
In this tutorial will walk you through the process of building Springboot application that uses Spring Data JPA to store and retrieve data using in memory h2 relation database. Spring Data JPA make it easier to integrated data access technologies i.e. relational and non-relational databases, map-reduce frameworks, and cloud-based data services through java code.
Features
• Powerful repository and custom object-mapping abstractions
• Dynamic query derivation from repository method names
• Implementation domain base classes providing basic properties
• Support for transparent auditing (created, last changed)
• Possibility to integrate custom repository code
• Easy Spring integration via JavaConfig and custom XML namespaces
• Advanced integration with Spring MVC controllers
• Experimental support for cross-store persistence
Architecture:
Draw a diagram
How to Accessing Data with JPA with New project or existing project?
navigate to https://start.spring.io to create a project.
Choose either Gradle or Maven and the language you want to use and language as java.
Click Dependencies and select Spring Data JPA and then H2 Database.
Click Generate. This will download a your project as Zip file.
Extract the project created in you desired folder.
Open the project in your favorite IDE
Create an Entity Class Customer and add desired fields with JPA annotation
Create CustomerRepository that extends CurdRepository which will provide the ability to perform CRUD operation into database.
Add findByLastName, findById custom methods to fetch records based on lastName and id
Create a CustomerController class that will accepts request from client to create, read, update and delete records.
Run the application
Using Postman send request to server and verify its working as expected
Summary
Congratulations! You have written a simple application that uses Spring Data JPA to save objects to and fetch them from a database, all without writing a concrete repository implementation.