### what is JPA

  • JPA is a Java API for managing persistence and object/relational mapping in Java EE and Java SE environments
  • The latest specification for JSR 338: Java Persistence “2.1” https://jcp.org/en/jsr/detail?id=3389
  • Implementation: EclipseLink; Hibernate ; Apache Open JPA

### core concepts ##### Entity classes

  • Entity annotations must be used in Entity classes (javax.persistence.Entity package)
  • There must be a no-argument constructor
  • If called remotely, the class must implement the Serializable interface
  • Unique object identifiers: primary key (javax.persistence.id); The composite primary key (EmbeddedId and IdClass) ##### relationship
  • One-to-one @ OneToOne
  • A pair of the @onetomany more
  • Many-to-one @ ManyToOne
  • Many-to-many @ManyToMany ##### Describes the EntityManager interface
  • Defines methods to interact with the persistence context
  • Create and delete persistent entity instances and find entities by their primary keys
  • Allows queries on entities

### What is Spring Data JPA

  • Part of the Spring Data family
  • Enhancements to the JPA-based data access layer

### Spring Data JPA interface

  • CurdRepository add, delete, modify, and query
  • PagingAndSortingRepository paging and sorting # # # # # custom interface First of all to remember that inherit the Repository interface (or its subclasses interface)