Beginning Spring Data: Data Access and Persistence for Spring Framework 6 and Boot 3
Use the popular Spring Data project for data access and persistence using various Java-based APIs such as JDBC, JPA, MongoDB, and more.
This book shows how to easily incorporate data persistence and accessibility into your microservices, cloud-native applications, and monolithic enterprise applications. It also teaches you how to perform unit and performance testing of a component that accesses a database. And it walks you through an example of each type of SQL and NoSQL database covered.
After reading this book, you’ll be able to create an application that interacts with one or multiple types of databases, and conduct unit and performance testing to analyze possible problems. Source code is available on GitHub.
What You’ll Learn
- Become familiar with the Spring Data project and its modules for data access and persistence
- Explore various SQL and NoSQL persistence types
- Uncover the persistence and domain models, and handle transaction management for SQL
- Migrate database changes and versioning for SQL
- Dive into NoSQL persistence with Redis, MongoDB, Neo4j, and Cassandra
- Handle reactive database programming and access with R2DBC and MongoDB
- Conduct unit, integration, and performance testing, and more
Who This Book Is For
Experienced Java software application developers; programmers with experience using the Spring framework or the Spring Boot micro framework
Table of Contents About the Author About the Technical Reviewer Acknowledgments Introduction Part I: Introduction Chapter 1: Application Architecture Why Persistence Is So Important The History of Persistence JDBC JDBC Driver Type 1: The JDBC-ODBC Bridge Type 2: Client Based Type 3: Two-Tier Architecture Type 4: Wire Protocol Drivers How to Connect with a Database EJB EJB Types JPA Spring Data Object Mapping Repository Support Architectures Types Layers Benefits Drawbacks Hexagonal Components Benefits Drawbacks Persistence Design Patterns Data Access Object (DAO) Repository Pattern Data Transfer Object (DTO) Specification Pattern Other Patterns Summary Chapter 2: Spring Basics and Beyond Spring Basics Spring Boot Basic Application Setup Creating an API Using Spring Initialzr Creating an API in the IDE How to Run the Application Best Practices Preventing Conflicts with the Dependencies Documenting the Endpoints Logging All the Details Maintaining and Updating the Dependencies Summary Chapter 3: Spring Data and Different Types of Persistence What Is Spring Data? How Does Spring Data Work? Spring Data Code Example Core Concepts Object Mapping Repositories Automatic Custom Queries Manual Custom Queries Implementing Repository Methods Summary Part II: SQL Persistence Chapter 4: Persistence and Domain Model JPA Configuration Using Annotations Entity Columns Primitive Types Character Types Date and time types Binary Types Other Types Non-Persistent Attributes Primary Key and Generators Types of Relationships Lazy and Eager Loading Ordering Types of Inherence Mapped Superclass Table per Class Hierarchy Table per Subclass with Joins Table per Class Embeddable Class Listening and Auditing Events Validating the Schema Summary Chapter 5: Transaction Management What Is a Transaction? What Is ACID? Isolation Problems Isolation Levels Locking Types How Do These Concepts Work in Spring Data? Transactional Properties Transaction Template Optimistic Locking Summary Chapter 6: Versioning or Migrating Changes Versioning Changes in a Database Libraries That Implement Versioning Flyway Liquibase Which Library Does the Versioning? Integrating Libraries in Spring Boot Liquibase Flyway Best Practices Feature Flags Implementing Feature Flags Including a Header Including a Library Best Practices Summary Part III: NoSQL Persistence Chapter 7: Redis: Key/Value Database What Is Redis? Spring Data Structures Database and Connection Settings Connecting with Primary/Secondary Nodes Object Mapping and Conversion Defining Custom Repositories Queries by Example Summary Chapter 8: MongoDB: Document Database What Is a Document Store? Possible Uses Cases Implementations What Is MongoDB? Introduction Spring Data Mongo Database and Connection Settings Annotations for Entities Access Using Repositories MongoDB Keywords for Repositories Defining Queries Writing the Query Using Annotations Queries by Example Using MongoTemplate with Custom Repositories Summary Chapter 9: Neo4j: Graph Database What Is a Graph Database? Possible Uses Cases Implementations What Is Neo4j? Introduction Spring Data Neo4j Database and Connection Settings Annotations for Entities Access Using Repositories Writing the Query Using Annotations Custom Repositories Queries by Example Summary Chapter 10: Cassandra: Wide-Column Database What Is Cassandra? Structure Configuration Database and Connection Settings Defining Custom Repositories Defining a TTL Summary Part IV: Advanced testing and best practices Chapter 11: Reactive Access What Is Reactive Access? Modifying Queries to Be Reactive Non-Relational Databases Relational Databases Considerations Summary Chapter 12: Unit and Integration Testing Unit Testing with Mocks Integration Testing with a Database Testcontainers Testcontainers vs. Embedded Using Testcontainers Multiple Integration Tests Initialization Strategies Potential Problems Summary Chapter 13: Detecting Performance Issues Low-Performance Problems Detecting Problems Analyzing Query Performance Analyzing Query Complexity Checking the Performance of an Endpoint Summary Chapter 14: Best Practices Compressing Information Reducing Transferred Information Using Optional in Custom Queries Using Lazy in Relationships Persisting Multiples Elements Using Master/Slave or Replicas Using Cache to Reduce Access Summary Appendix A: Setting up Environment Tools Installing Java Installing Maven Installing Git Installing IntelliJ Installing Docker Appendix B: Recommended and Alternative Tools IDEs REST Tools Databases Cassandra MongoDB MySQL Neo4j PostgreSQL Redis Appendix C: Opening a Project Appendix D: Install and Configure a Relational Database MySQL Step 1: Install the Database on Your Local Machine Step 2: Install the Client to Access the Database Step 3: Configure the Connection Step 4: Create the Schema Step 5: Load the Data PostgreSQL Step 1: Install the Database on Your Local Machine Step 2: Install the Client to Access the Database Step 3: Configure the Connection Step 4: Create the Schema Step 5: Load the Data Databases Using Docker Appendix E: Installing and Configuring Non-Relational Databases Redis MongoDB Cassandra Neo4j Appendix F: Further Reading General Relational Databases Non-Relational Databases Index
How to download source code?
1. Go to:
2. In the Find a repository… box, search the book title:
Beginning Spring Data: Data Access and Persistence for Spring Framework 6 and Boot 3, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.