← Spring Boot learning path
Spring Boot · Module 4 of 10

Spring Data JPA

Store and query data with repositories and entities.

📖 Key ideas

  1. @Entity maps a class to a table; @Id marks the primary key.
  2. interface UserRepository extends JpaRepository<User, Long>.
  3. Built-in methods: save, findById, findAll, deleteById.
  4. Derived queries: findByEmail(String email).
  5. Hibernate is the default JPA implementation.
💡 Real-life example: A repository is a librarian: ask "find by email" and it fetches the record without you writing SQL.
@EntityClass mapped to a table
JpaRepositoryReady CRUD repository
Derived queryQuery from the method name
HibernateJPA implementation