Back to Lessons

Spring Data JPA Repositories

April 5, 2026

JPA Entity Management

CRUD operations with automatic repository implementation.

Entity Example

@Entity
public class Product {
    @Id @GeneratedValue private Long id;
    private String name;
    private BigDecimal price;
    @ManyToOne private Category category;
}

Repository Methods

  • findAll(), save(), deleteById()
  • findByName(String name)
  • Page findAll(Pageable pageable)
  • Custom @Query annotations