Spring-Data

Access your data easily

Part 1 - Spring Data Repositories

Created by Marcel Becker

About me

  • Software Developer @ 1&1 Internet AG
  • http://tuxdevelop.github.io
  • MailTo: tuxdevelop@gmail.com
  • github: https://github.com/tuxdevelop

Table of Content

  • Overview
  • Part 0 - Infrastructure
  • Part 1 - Repository Introduction
  • Part 2 - CRUD Repository
  • Part 3 - Paging & Sorting
  • Part 4 - Own Base Repositories
  • Part 5 - Dynamic Queries
  • Part 6 - Custom Repository Implementations
  • Part 7 - Spring Data Rest
    • Part 7.1 - HAL_JSON Traverson

Overview

spring.io - Spring-Data

Error: Embedded data could not be displayed.

Part 0 - Infrastructure

Summary

  • Set up Maven
  • Basic JPA Infrastructure
  • Populate test data

Part 1 - Repository
Introduction

Goals

  • Find Customer by Id
  • Find Customer by first name

Summary

  • Introduce Repository Interface
  • Introduce Base Repository Implementation
  • Introduce Query Builder

Part 2 - CRUD Repository

Goals

  • Using CRUD Methods
  • Overriding existing Methods

Summary

  • Introduce CRUD Interface
  • UpCast of return values

Part 3 - Paging & Sorting

Goals

  • Use Paging & Sorting
  • Overriding Method Behavior with Annotations
  • Get Customers of a city

Summary

  • Introduce Paging and Sorting
  • Use @Transactional to define Timeout
  • Customized Queries

Part 4 - Define Base
Repositories

Goals

  • Read Only Repository

Summary

  • Defined own ReadOnlyRepository
  • @NoRepositoryBean

Part 5 - Dynamic Queries

Goals

  • find a Customer by
    • firstName
    • lastName
    • or both

Summary

  • Introduced QueryDSL
  • Easily Set Up Dynamic Queries on Client Side

Part 6 - Custom Repository Implementations

Goals

  • Implementations of Delete Methods for Orders beyond a given price

Summary

  • Defined Custom Repository Impl
  • Combined Impl with Repository Interface

Part 7 - Spring Data Rest

Goals

  • Expose Repositories as RESTful Service

Summary

  • @RepositoryRestController

Part 7.1 - HAL_JSON Traversion

Goals

  • Usage of the REST API
    • RestTemplate
    • Traversion

Summary

  • Accessing Service via RestTemplate
  • Traverse through HAL_JSON Tree via Traversion
  • @Projection

What is Next?

  • Spring-Data-MongoDB
  • Spring-Data-Solr
  • Spring-Data-Repositories in CDI Environments

Resources

  • tuxdevelop.github.io
  • https://github.com/tuxdevelop