What is Spring data JPA ?

  • The too much boilerplate code has to be written to execute simple queries as well as perform pagination, and auditing.
  • It aims to significantly improve the implementation of data access layers by reducing the effort to the amount that’s actually needed.
  • As a developer, you write your repository interfaces, including custom finder methods, and Spring will provide the implementation automatically.
  • We can remove some boilerplate code by creating an abstract base repository class that provides CRUD operations for our entities. This means that we can create concrete repositories by extending that base repository class.
  • It has a lot of customization points, including items like query auto-generation by convention, query hints, and auditing.

Features

  • Sophisticated support to build repositories based on Spring and JPA
  • Support for Querydsl predicates and thus type-safe JPA queries
  • Transparent auditing of domain class
  • Pagination support, dynamic query execution, ability to integrate custom data access code
  • Validation of @Query annotated queries at bootstrap time
  • Support for XML based entity mapping
  • JavaConfig based repository configuration by introducing @EnableJpaRepositories.

Advantages

  • Don’t need to write persisting, updating, deleting or searching logic.
  • Reduce a lot of basic DB code.
  • No need to create implementation classes to perform basic CRUD operations.
  • Just extends Repository class and it takes the domain class to manage as well as the id type of domain class as type arguments in Interface.
  • The interface acts as a marker interface to capture the type of work and to help you to discover interfaces that extend this one.

Types of Repositories

public interface Repository public interface CRUDRepository
public interface PagingAndSortingRepository
public interface JpaRepository

For more detail, Please watch below video –

Thanks for reading πŸ™‚

Please Subscribe our you tube channel Almighty Java

 

Leave a comment