Spring-Data-JPA入门

前言

Spring Data JPA, part of the larger Spring Data family, makes it easy to easily implement JPA based repositories. This module deals with enhanced support for JPA based data access layers. It makes it easier to build Spring-powered applications that use data access technologies.

Implementing a data access layer of an application has been cumbersome for quite a while. Too much boilerplate code has to be written to execute simple queries as well as perform pagination, and auditing. Spring Data JPA 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.

特性

  • 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

介绍

Spring Data Jpa 是应用于 Dao 层的一个 ORM 框架,用于简化数据库层开发。

作用和 MyBatis 框架一样,但是在使用方式和底层机制上不同。最大的区别点是,Spring Data Jp 在进行 Dao 层开发的时候,很多场景不需要写 sql 语句即可实现,由 Spring 提供。

概览

  • Spring Data Jpa介绍回顾

  • Spring Data Jpa、Jpa规范和Hibernate之间的关系

  • 基于案例实现Spring Data Jpa的应用

    • 使用步骤
    • 接口方法、使用方式
  • Spring Data Jpa实现源码分析

posted @ 2021-12-25 13:01  灯塔下的守望者  阅读(45)  评论(0编辑  收藏  举报