Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Spring Data Repositories - A Deep Dive
Search
Oliver Drotbohm
October 17, 2012
Programming
2
610
Spring Data Repositories - A Deep Dive
Slides of my talk at SpringOne2GX 2012.
Oliver Drotbohm
October 17, 2012
Tweet
Share
More Decks by Oliver Drotbohm
See All by Oliver Drotbohm
It Takes Two to Tango – Designing Module Interactions in Modulithic Spring Applications
olivergierke
5
710
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
940
Spring Modulith – A Deep Dive
olivergierke
8
4.4k
Spring for the Architecturally Curious Developer
olivergierke
5
1.8k
Spring Boot 3 & Spring Framework 6
olivergierke
4
2k
Architecturally-evident Java Applications with jMolecules
olivergierke
9
2.9k
A Deep Dive into Spring Application Events
olivergierke
12
3.3k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
970
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
750
Other Decks in Programming
See All in Programming
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
2
990
2025 年のコーディングエージェントの現在地とエンジニアの仕事の変化について
azukiazusa1
4
2k
個人軟體時代
ethanhuang13
0
280
Zendeskのチケットを Amazon Bedrockで 解析した
ryokosuge
3
240
AI OCR API on Lambdaを Datadogで可視化してみた
nealle
0
220
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
100
Vue・React マルチプロダクト開発を支える Vite
andpad
0
110
レガシープロジェクトで最大限AIの恩恵を受けられるようClaude Codeを利用する
tk1351
4
1.5k
Go言語での実装を通して学ぶLLMファインチューニングの仕組み / fukuokago22-llm-peft
monochromegane
0
110
MCPでVibe Working。そして、結局はContext Eng(略)/ Working with Vibe on MCP And Context Eng
rkaga
4
680
CSC305 Summer Lecture 12
javiergs
PRO
0
130
Google I/O recap web編 大分Web祭り2025
kponda
0
2.9k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
40
2k
Site-Speed That Sticks
csswizardry
10
800
GraphQLとの向き合い方2022年版
quramy
49
14k
Gamification - CAS2011
davidbonilla
81
5.4k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Building Adaptive Systems
keathley
43
2.7k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
61k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Practical Orchestrator
shlominoach
190
11k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
790
Transcript
Spring Data Repositories A Deep Dive Oliver Gierke, Senior Member
Technical Staff
[email protected]
- @olivergierke © 2012 SpringOne 2GX. All rights reserved. Do not distribute without permission.
2 Oliver Gierke Spring Source engineer Project lead Core/JPA/MongoDB
[email protected]
www.olivergierke.de olivergierke
3 Spring Data Modern Data Access For Enterprise Java NoSQL
JPA JDBC Redis Big Data Hadoop HBase MongoDB Neo4j REST exporter Roo Hive Pig Querydsl Repositories 1 free copy per attendee! Gemfire Splunk
4 Hands on
Sample code https://github.com/olivergierke/repositories-deepdive 5
6 Step 0 Initial project setup
7 Summary Use kickstart projects to ease setup
8 Step 1 Basic JPA infrastructure setup
9 " Persistence technology of choice is JPA. e application
uses JavaConfig and sample data contained in data.sql.
10 Summary Easy setup through JavaConfig XML-less JPA configuration
11 Step 2 Quickstart
12 " e implementation of the persistence layer will be
based on the Spring Data repositories abstraction. Customers can be saved, looked up by their id, email address.
13 Summary Interface-based programming model No implementation required Queries derived
from method names
14 Step 3 Extended CRUD methods
15 " Customers can be deleted and obtained all at
once.
16 Summary Switched to CrudRepository Exposed CRUD methods Broad API
exposed
17 Step 4 Pagination
18 " Customers can be accessed page by page.
19 Summary Switched to PagingAndSortingRepository Exposed CRUD methods and paging
ones Broad API exposed
20 Step 5 Re-declaring existing CRUD methods
21 " CustomerRepository.findAll() should rather return a List. e transaction
timeout for save(…) should be customized to 10 seconds.
22 Summary Re-declare methods to customize Return types Annotation config
(Tx, Locking)
23 Step 6 Introducing a read-only repository base interface
24 " Orders shall be accessible in read-only mode only.
25 Summary Craft custom base interface Return types Annotation config
(Tx, Locking)
26 Step 7 Using manually defined queries
27 " As a user, I want to look up
products by their custom attributes.
28 Summary @Query annotation JPA named queries Spring Data named
queries
29 Step 8 Flexible predicate execution
30 " As a user, I want to search for
customers by first name, last name, email address and any combination of them
31 Summary Querydsl - type safe queries for Java QuerydslPredicateExecutor
Side track: Repository proxies 32
Proxy mechanism Using Spring's JDK proxy support Bootstrap through Factory
Spring FactroyBean / CDI XML namespace / @EnableRepositories 33
Proxy mechanism Query interface CRUD implementation class QueryDslPredicateExecutor Custom implementation
extension 34
35 Step 9 Custom implementations for repositories
36 " As an admin user, I'd like to delete
all products beyond a given price.
37 Summary Provide custom implementation Base class support (Querydsl)
Stuff on top Spring MVC integration Spring Data REST Spring
Roo 38
Up and beyond 39
40 Supported modules JPA MongoDB Neo4j Gemfire
41 Community implementations Spring Data Solr FuzzyDB (Cassandra)
42 Further sessions Spring Data and Data Grids - Wed,
12:45pm Spring Data Neo4j - Wed, 2:45pm Lightning Talks - Wed, 4:30pm Spring Data REST - Thu, 12:45pm
Summary 43
Interface-based programming model 44
Start simple, get more sophisticated 45
Declarative query execution 46
Flexible predicate execution 47
Custom implementation 48
CDI integration 49