Spring Data: Modern Data Access for Enterprise Java cover

Spring Data: Modern Data Access for Enterprise Java

No rating yet
Chapters
40
ISBN
9787564142001

Tags

Summary

This book is the authoritative introductory guide to the Spring Data project. In the Java enterprise world of the time, relational databases reigned supreme, but with the rise of NoSQL and new data technologies such as Hadoop, RDBMS was no longer a one-size-fits-all solution. Written jointly by the Spring Data project lead and the leads of its core modules, the book explains how Spring Data offers a unified programming model that lets developers efficiently connect to Redis, HBase, MongoDB, Neo4j, GemFire, and other data stores. The book is divided into several parts: background, relational databases, NoSQL, rapid application development, and big data. Part I introduces the origins of the Spring Data project, the classification of NoSQL stores, and how to import the sample projects, and focuses on the Repository abstraction: deriving queries from method names, defining query methods, pagination and sorting, manually implementing repository methods, and type-safe queries with Querydsl. Part II discusses the differences between Spring Data JPA repositories and traditional JPA approaches, as well as type-safe JDBC programming with Querydsl SQL. Part III goes deep into MongoDB document stores and Neo4j graph databases, covering the mapping subsystem, MongoTemplate, graph repository operations, collaborative filtering recommendations, and other advanced use cases, and introduces Redis key-value storage, atomic counters, publish-subscribe, and the caching abstraction. Part IV introduces rapid persistence-layer development with Spring Roo and exporting JPA entities as RESTful services with the REST Repository Exporter. Part V covers Spring for Apache Hadoop, demonstrating HDFS scripting, MapReduce job scheduling, analyzing Apache logs with Hive and Pig, and building data pipelines with Spring Batch and Spring Integration, finally exporting data to JDBC, MongoDB, and Splunk. The book is threaded with multiple runnable sample projects whose code can be imported into an IDE and debugged directly. One caveat: the book was written in 2012 and covers the Spring Data versions and APIs of that time; some class names and configuration approaches (such as XML namespace configuration) now differ from current versions. It is suitable as a reference for understanding Spring Data’s design philosophy rather than as an API manual for the latest version.

Editor's review

一本被低估的「一站式」Spring Data 入门书。它的难得之处在于作者阵容本身就是项目核心:Mark Pollack 是 Spring Data 项目负责人,Oliver Gierke 主导 Spring Data JPA、MongoDB 与核心模块,Thomas Risberg 负责 MongoDB 与 JDBC Extensions,Michael Hunger 是 Spring Data Neo4j 项目负责人。项目作者亲自讲设计取舍,读起来能明白「为什么要这么设计」,而不只是「API 怎么调」。 结构上,全书没有把各类存储割裂成互不相干的章节,而是先花相当篇幅讲清 Repository 抽象与 Querydsl 类型安全查询这套统一底座,再分别落到 JPA、MongoDB、Neo4j、Redis、HBase 上。你会发现同样的仓库接口、同样的方法名推导查询,可以横跨文档库、图库、键值库使用,这种「一致编程模型」的体验正是 Spring Data 的核心价值,也是本书最有说服力的地方。 后半部分把视角抬到大数据:HDFS 脚本化、MapReduce 调度、Hive 与 Pig 分析 Apache 日志,以及用 Spring Batch 与 Spring Integration 串起从日志采集到 HDFS、再到 JDBC/MongoDB/Splunk 的完整管道。对需要把「业务系统」和「数据平台」打通的 Java 工程师,这部分思路比代码更值钱。 要提醒的是:原书出版于 2012 年,中文影印版 2013 年推出,示例基于当时的 Spring Data 版本。今天的 Spring Boot 自动配置、Reactive 仓库、Spring Data R2DBC 等均未覆盖,部分 XML 配置写法已过时。把它当「理解原理与设计思想」的书来读,收益远大于当查询手册。

Who it's for

A good fit for

  • 已有 Spring 基础、想系统了解 Spring Data Repository 抽象的 Java 后端工程师
  • 需要在项目中引入 MongoDB、Neo4j、Redis 等 NoSQL 存储的开发人员
  • 负责把业务系统与 Hadoop 数据平台打通的架构师与技术负责人
  • 做 Spring 技术选型调研、需要理解各模块设计取舍的团队骨干

Not a good fit for

  • Java 与 Spring 零基础、尚未写过 IoC 与 JPA 示例的初学者
  • 只想查最新 Spring Boot 3 / Spring Data 2024 版 API 用法的读者
  • 主要做前端或非 JVM 技术栈、不涉及 Spring 生态的开发者

Reading tips

  1. 先读第一部分讲 Repository 抽象与 Querydsl 的章节,这是全书理解其他模块的钥匙。
  2. 按项目实际用到的存储挑读对应章节,不必按顺序通读 MongoDB、Neo4j、Redis 三部分。
  3. 动手把书中的示例工程导入 IDE 跑通,再用当前 Spring Boot 版本改造一遍,能更清楚 API 演变。
  4. 读大数据部分时重点关注 Spring Batch 与 Spring Integration 的管道设计思路,代码层面请结合新版文档。
  5. 遇到与现行版本不一致的写法,直接查 Spring Data 官方参考文档对照,不要强行套用旧配置。

Contents

  1. Foreword
  2. Preface
  3. Part I. Background
  4. The Spring Data Project
  5. NoSQL Data Access for Spring Developers
  6. General Themes
  7. The Domain
  8. The Sample Code
  9. Importing the Source Code into Your IDE
  10. Repositories: Convenient Data Access Layers
  11. Quick Start
  12. Defining Query Methods
  13. Query Lookup Strategies
  14. Query Derivation
  15. Pagination and Sorting
  16. Defining Repositories
  17. Fine-Tuning Repository Interfaces
  18. Manually Implementing Repository Methods
  19. IDE Integration
  20. Type-Safe Querying Using Querydsl
  21. Introduction to Querydsl
  22. Generating the Query Metamodel
  23. Build System Integration
  24. Supported Annotation Processors
  25. Querying Stores Using Querydsl
  26. Integration with Spring Data Repositories
  27. Part II. Relational Databases
  28. JPA Repositories
  29. The Sample Project
  30. The Traditional Approach
  31. Bootstrapping the Sample Code
  32. Using Spring Data Repositories
  33. Transactionality
  34. Repository Querydsl Integration
  35. Type-Safe JDBC Programming with Querydsl SQL
  36. The Sample Project and Setup
  37. The HyperSQL Database
  38. The SQL Module of Querydsl
  39. The Database Schema
  40. Implementation of the Sample Project

FAQ

这本书有正式的中文翻译版吗?
国内出版的是东南大学出版社 2013 年的「影印版」,正文仍是英文原版内容,只加了中文书名与出版信息,并非逐章翻译。市面上流传的中文 PDF 多为该影印版扫描件,阅读时需具备一定英文技术阅读能力。
书名里的「Spring Data」和 Spring Framework 是一回事吗?
不是。Spring Framework 提供 IoC 容器、MVC、事务等基础能力;Spring Data 是建立在其上的独立项目族,专注简化数据访问,包含 Spring Data JPA、MongoDB、Neo4j、Redis、HBase 等模块,核心是统一的 Repository 抽象。
书里的代码还能直接跑吗?内容是否过时?
原书基于 2012 年前后的 Spring Data 版本,大量使用 XML 命名空间配置。今天 Spring Boot 自动配置、Reactive 仓库、R2DBC 等均未涉及,部分类名与配置方式已变化。建议把示例当作理解设计原理的参考,实际开发以官方最新文档为准。
需要先掌握哪些知识再读这本书?
建议先熟悉 Java 语言、Spring 的依赖注入与配置、JDBC 或 JPA 的基本用法,并了解什么是文档数据库和图数据库。书中第一部分会给 NoSQL 做背景铺垫,但完全没有 Spring 经验的读者读起来会比较吃力。
只想学 Spring Data JPA,值得买整本吗?
若只做关系型数据库,第一部分 Repository 抽象加第二部分 JPA 仓库已能覆盖核心内容,但这两部分只占全书约三分之一。建议先看官方参考文档;如果同时要接触 NoSQL 或 Hadoop,本书的横向对比价值才真正体现。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

Top rated in the same category