官术网_书友最值得收藏!

Spring Data

Spring Data is an interesting module that provides the easiest way to manage application data with Spring-based programming. The project is an umbrella project, with subprojects to support different databases technologies, even relational and nonrelational databases. The Spring Team supports some databases technologies, such as Apache Cassandra, Apache Solr, Redis, and JPA Specification, and the community maintains the other exciting projects, such as ElasticSearch, Aerospike, DynamoDb, and Couchbase. The full list of projects can be found at http://projects.spring.io/spring-data.

The goal is to remove the boilerplate code from the persistence code. In general, the data access layer is quite similar, even in different projects, differing only in the project model, and Spring Data provides a powerful way to map the domain model and repository abstraction.

There are some central interfaces; they're a kind of marker to instruct the framework to choose the correct implementation. Under the hood, Spring will create a proxy and delegate the correct implementation. The amazing thing here is that developers don't have to write any persistence code and then take care of this code; they simply choose the required technology and Spring takes care of the rest.

The central interfaces are CrudRepository and PagingAndSortingRepository, and their names are self-explanatory. CrudRepository implements the CRUD behaviors, such as create, retrieval, update, and deletePagingAndSortingRepository is an extension of CrudRepository and adds some features such as paging and sorting. Usually, we will find derivations of these interfaces such as MongoRepository, which interacts with MongoDB database technology.

Some common annotations are  @Query, @Id, and  @EnableJpaRepositories.
主站蜘蛛池模板: 南靖县| 镇江市| 朝阳市| 固安县| 苗栗市| 厦门市| 驻马店市| 安图县| 定远县| 中山市| 双牌县| 龙南县| 海南省| 承德县| 贡觉县| 渭源县| 双柏县| 寿宁县| 鲁山县| 常宁市| 宣威市| 舟山市| 上虞市| 郯城县| 泸西县| 宜兴市| 响水县| 本溪市| 镇沅| 元江| 巴楚县| 东兰县| 福州市| 黑龙江省| 额济纳旗| 宝坻区| 黄梅县| 黑龙江省| 曲水县| 铁力市| 织金县|