Creating Entities & Repositories
Define JPA entities to represent your data model and use Spring Data repositories for data access.
What are JPA Entities?
Welcome to creating your data model! In Spring Boot with JPA, an Entity is a plain Java object that represents a table in your database.
Think of it as a blueprint for the rows in your table. Each instance of an entity class corresponds to a single row in the database table.
Marking a Class as an Entity
To tell Spring Boot that a Java class is an entity, we use the @Entity annotation. This annotation comes from the Java Persistence API (JPA).
When Spring sees @Entity, it knows to map this class to a database table. By default, the table name will be the same as the class name (e.g., a Product class maps to a Product table).