Getting Started with Spring Data JPA
Learn how to use Spring Data JPA to store and retrieve data from your database.
See Also - Marco Codes
In addition to this tutorial, we recommend you check out Marco Codes - JDBC Tutorial - Crash Course to learn about:
- How to use JDBC, i.e. the basic API that every Java program uses to access databases
- Understand what JDBC drivers are and where to get them
- How to use an embedded H2 database, in addition to the usual suspects like MySQL or Postgres
- Fire off SQL select, insert, update and delete statements from Java
- Connection pools and the overall Java database framework/library landscape
Introduction
Getting started with Spring Data JPA.
Creating a New Spring Boot Project
Use the Spring Initializr to create a new Spring Boot project.
Creating an Employee Entity
Create a JPA entity representing an Employee.
Creating a Repository Interface
Create a Spring Data repository for CRUD operations.
Configuring your Database
Configure the application to connect to our database.
Writing from your Application to the Database
Insert four employees into the database.
Creating a Data Source
In the Database View, create a data source for our database.
Calling a Custom Query
Query the database for employees with spaces in their last name.
Summary
Shortcuts, GitHub repository and other resources