Spring Boot JPA
- JPA is not a framework. It defines a concept that can be implemented by any framework.
- Spring Boot JPA is a Java specification for managing relational data in Java applications. It allows us to access and persist data between Java object/ class and relational database. JPA follows Object-Relation Mapping (ORM). It is a set of interfaces. It also provides a runtime EntityManager API for processing queries and transactions on the objects against the database. It uses a platform-independent object-oriented query language JPQL (Java Persistent Query Language).
- Features
- It is a powerful repository and custom object-mapping abstraction.
- It supports for cross-store persistence. It means an entity can be partially stored in MySQL and Neo4j (Graph Database Management System).
- It dynamically generates queries from queries methods name.
- The domain base classes provide basic properties.
- It supports transparent auditing.
- Possibility to integrate custom repository code.
- It is easy to integrate with Spring Framework with the custom namespace.
- JPA annotations
- @Repository
- @Entity
- @Id
- @GeneratedValue
- @OneToMany
- @ManyToOne
- @Query
Pageable pageable = PageRequest.of(int pageNum, int size, (Sort sort));
Page<T> pageT = xxService.findAllByxx(X xx, pageable);
List<T> listT = xxService.findAllByxx(X xx, pageable);
// Page<T> obtain some extra information about page object, sum of T objects etc.