Spring Data

Book description

You can choose several data access frameworks when building Java enterprise applications that work with relational databases. But what about big data? This hands-on introduction shows you how Spring Data makes it relatively easy to build applications across a wide range of new data access technologies such as NoSQL and Hadoop.

Through several sample projects, you’ll learn how Spring Data provides a consistent programming model that retains NoSQL-specific features and capabilities, and helps you develop Hadoop applications across a wide range of use-cases such as data analysis, event stream processing, and workflow. You’ll also discover the features Spring Data adds to Spring’s existing JPA and JDBC support for writing RDBMS-based data access layers.

  • Learn about Spring’s template helper classes to simplify the use ofdatabase-specific functionality
  • Explore Spring Data’s repository abstraction and advanced query functionality
  • Use Spring Data with Redis (key/value store), HBase(column-family), MongoDB (document database), and Neo4j (graph database)
  • Discover the GemFire distributed data grid solution
  • Export Spring Data JPA-managed entities to the Web as RESTful web services
  • Simplify the development of HBase applications, using a lightweight object-mapping framework
  • Build example big-data pipelines with Spring Batch and Spring Integration

Publisher resources

View/Submit Errata

Table of contents

  1. Spring Data
  2. Dedication
  3. Dedication
  4. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  5. Foreword
  6. Preface
    1. Overview of the New Data Access Landscape
    2. How to Read This Book
    3. Conventions Used in This Book
    4. Using Code Examples
    5. Safari® Books Online
    6. How to Contact Us
    7. Acknowledgments
  7. I. Background
    1. 1. The Spring Data Project
      1. NoSQL Data Access for Spring Developers
      2. General Themes
      3. The Domain
      4. The Sample Code
        1. Importing the Source Code into Your IDE
          1. STS/Eclipse
          2. IntelliJ IDEA
    2. 2. Repositories: Convenient Data Access Layers
      1. Quick Start
      2. Defining Query Methods
        1. Query Lookup Strategies
        2. Query Derivation
          1. Property expressions
        3. Pagination and Sorting
      3. Defining Repositories
        1. Fine-Tuning Repository Interfaces
        2. Manually Implementing Repository Methods
      4. IDE Integration
        1. IntelliJ IDEA
    3. 3. Type-Safe Querying Using Querydsl
      1. Introduction to Querydsl
      2. Generating the Query Metamodel
        1. Build System Integration
        2. Supported Annotation Processors
        3. Querying Stores Using Querydsl
      3. Integration with Spring Data Repositories
        1. Executing Predicates
        2. Manually Implementing Repositories
  8. II. Relational Databases
    1. 4. JPA Repositories
      1. The Sample Project
      2. The Traditional Approach
      3. Bootstrapping the Sample Code
      4. Using Spring Data Repositories
        1. Transactionality
        2. Repository Querydsl Integration
    2. 5. Type-Safe JDBC Programming with Querydsl SQL
      1. The Sample Project and Setup
        1. The HyperSQL Database
        2. The SQL Module of Querydsl
        3. Build System Integration
        4. The Database Schema
        5. The Domain Implementation of the Sample Project
      2. The QueryDslJdbcTemplate
      3. Executing Queries
        1. The Beginning of the Repository Implementation
        2. Querying for a Single Object
        3. The OneToManyResultSetExtractor Abstract Class
        4. The CustomerListExtractor Implementation
        5. The Implementations for the RowMappers
        6. Querying for a List of Objects
      4. Insert, Update, and Delete Operations
        1. Inserting with the SQLInsertClause
        2. Updating with the SQLUpdateClause
        3. Deleting Rows with the SQLDeleteClause
  9. III. NoSQL
    1. 6. MongoDB: A Document Store
      1. MongoDB in a Nutshell
        1. Setting Up MongoDB
        2. Using the MongoDB Shell
        3. The MongoDB Java Driver
      2. Setting Up the Infrastructure Using the Spring Namespace
      3. The Mapping Subsystem
        1. The Domain Model
          1. Addresses and email addresses
          2. Customers
          3. Products
          4. Orders and line items
        2. Setting Up the Mapping Infrastructure
          1. Using the Spring namespace
          2. In Spring JavaConfig
        3. Indexing
        4. Customizing Conversion
          1. Implementing custom converters
          2. Registering custom converters
      4. MongoTemplate
      5. Mongo Repositories
        1. Infrastructure Setup
        2. Repositories in Detail
        3. Mongo Querydsl Integration
    2. 7. Neo4j: A Graph Database
      1. Graph Databases
      2. Neo4j
      3. Spring Data Neo4j Overview
      4. Modeling the Domain as a Graph
      5. Persisting Domain Objects with Spring Data Neo4j
        1. Neo4jTemplate
      6. Combining Graph and Repository Power
        1. Basic Graph Repository Operations
        2. Derived and Annotated Finder Methods
          1. Annotated finder methods
          2. Result handling
          3. Derived finder methods
      7. Advanced Graph Use Cases in the Example Domain
        1. Multiple Roles for a Single Node
        2. Product Categories and Tags as Examples for In-Graph Indexes
        3. Leverage Similar Interests (Collaborative Filtering)
        4. Recommendations
      8. Transactions, Entity Life Cycle, and Fetch Strategies
      9. Advanced Mapping Mode
      10. Working with Neo4j Server
      11. Continuing From Here
    3. 8. Redis: A Key/Value Store
      1. Redis in a Nutshell
        1. Setting Up Redis
        2. Using the Redis Shell
      2. Connecting to Redis
      3. Object Conversion
      4. Object Mapping
      5. Atomic Counters
      6. Pub/Sub Functionality
        1. Listening and Responding to Messages
      7. Using Spring’s Cache Abstraction with Redis
  10. IV. Rapid Application Development
    1. 9. Persistence Layers with Spring Roo
      1. A Brief Introduction to Roo
      2. Roo’s Persistence Layers
      3. Quick Start
        1. Using Roo from the Command Line
        2. Using Roo with Spring Tool Suite
      4. A Spring Roo JPA Repository Example
        1. Creating the Project
        2. Setting Up JPA Persistence
        3. Creating the Entities
        4. Defining the Repositories
        5. Creating the Web Layer
        6. Running the Example
      5. A Spring Roo MongoDB Repository Example
        1. Creating the Project
        2. Setting Up MongoDB Persistence
        3. Creating the Entities
        4. Defining the Repositories
        5. Creating the Web Layer
        6. Running the Example
    2. 10. REST Repository Exporter
      1. The Sample Project
        1. Interacting with the REST Exporter
        2. Accessing Products
        3. Accessing Customers
        4. Accessing Orders
  11. V. Big Data
    1. 11. Spring for Apache Hadoop
      1. Challenges Developing with Hadoop
      2. Hello World
      3. Hello World Revealed
      4. Hello World Using Spring for Apache Hadoop
      5. Scripting HDFS on the JVM
      6. Combining HDFS Scripting and Job Submission
      7. Job Scheduling
        1. Scheduling MapReduce Jobs with a TaskScheduler
        2. Scheduling MapReduce Jobs with Quartz
    2. 12. Analyzing Data with Hadoop
      1. Using Hive
        1. Hello World
        2. Running a Hive Server
        3. Using the Hive Thrift Client
        4. Using the Hive JDBC Client
        5. Apache Logfile Analysis Using Hive
      2. Using Pig
        1. Hello World
        2. Running a PigServer
        3. Controlling Runtime Script Execution
        4. Calling Pig Scripts Inside Spring Integration Data Pipelines
        5. Apache Logfile Analysis Using Pig
      3. Using HBase
        1. Hello World
        2. Using the HBase Java Client
    3. 13. Creating Big Data Pipelines with Spring Batch and Spring Integration
      1. Collecting and Loading Data into HDFS
        1. An Introduction to Spring Integration
        2. Copying Logfiles
        3. Event Streams
        4. Event Forwarding
        5. Management
        6. An Introduction to Spring Batch
        7. Processing and Loading Data from a Database
      2. Hadoop Workflows
        1. Spring Batch Support for Hadoop
        2. Wordcount as a Spring Batch Application
        3. Hive and Pig Steps
      3. Exporting Data from HDFS
        1. From HDFS to JDBC
        2. From HDFS to MongoDB
      4. Collecting and Loading Data into Splunk
  12. VI. Data Grids
    1. 14. GemFire: A Distributed Data Grid
      1. GemFire in a Nutshell
      2. Caches and Regions
      3. How to Get GemFire
      4. Configuring GemFire with the Spring XML Namespace
        1. Cache Configuration
        2. Region Configuration
        3. Cache Client Configuration
        4. Cache Server Configuration
        5. WAN Configuration
        6. Disk Store Configuration
      5. Data Access with GemfireTemplate
      6. Repository Usage
        1. POJO Mapping
        2. Creating a Repository
        3. PDX Serialization
      7. Continuous Query Support
  13. Bibliography
  14. Index
  15. About the Authors
  16. Colophon
  17. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  18. Copyright

Product information

  • Title: Spring Data
  • Author(s): Mark Pollack, Oliver Gierke, Thomas Risberg, Jon Brisbin, Michael Hunger
  • Release date: October 2012
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781449331887