Spring Boot, Hibernate, JPA and MySQL
Spring Boot is the most popular Java framework for building cloud-native applications, and Hibernate is the most popular object-relational mapping framework for implementing the JPA spec. This Spring Boot and JPA tutorial shows you how to use Hibernate to map Java objects to database tables in a MySQL database.
Spring Boot, JPA and Hibernate tutorial
This Spring Boot and Hibernate tutorial works through a simple bookstore example, with the following steps:
- Store data in a MySQL database table named BOOKS.
- A Java class named
Book
has properties that map to columns in the table. - Use Spring JPA annotations to describe the Java-to-MySQL mappings.
- Hibernate takes care of marshalling SQL queries over JDBC connections.
- Spring Boot stores the MySQL JDBC URL in its
application.properties
file. - Use Spring Web to create a REST API that exposes Spring JPA CRUD operations.
- Test the RESTful endpoints with OpenAPI and Swagger UI.
- Use OpenAI's ChatGPT to create an HTML and JavaScript web interface for the app.
A fun yet comprehensive Spring Boot project
The number of Java, Spring and database technologies used in the bookstore app may sound intimidating on the surface, but each API and tool is introduced logically and incrementally in a way that makes it easy to learn Spring Boot and Spring Data JPA.
If you want to learn how to create a Spring or Spring Boot application that integrates with JPA, Hibernate, REST APIs and browser-based technologies including Swagger, HTML and JavaScript, this Spring Boot tutorial is for you.
Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development; DevOps; Spring; and container-based technologies such as Docker, Swarm and Kubernetes.