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
April 04, 2013
Programming
4
160
Spring Data Repositories - A Deep Dive
Slides of my talk at BedCon 2013 in Berlin, Germany.
Oliver Drotbohm
April 04, 2013
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
590
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
840
Spring Modulith – A Deep Dive
olivergierke
7
4.1k
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
8
2.8k
A Deep Dive into Spring Application Events
olivergierke
12
3.2k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
920
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
700
Other Decks in Programming
See All in Programming
CDK開発におけるコーディング規約の運用
yamanashi_ren01
2
260
お前もAI鬼にならないか?👹Bolt & Cursor & Supabase & Vercelで人間をやめるぞ、ジョジョー!👺
taishiyade
7
4.2k
Rubyで始める関数型ドメインモデリング
shogo_tksk
0
140
Jakarta EE meets AI
ivargrimstad
0
480
ABEMA iOS 大規模プロジェクトにおける段階的な技術刷新 / ABEMA iOS Technology Upgrade
akkyie
1
220
CDKを使ったPagerDuty連携インフラのテンプレート化
shibuya_shogo
0
110
[JAWS DAYS 2025] 最近の DB の競合解決の仕組みが分かった気になってみた
maroon1st
0
140
メンテが命: PHPフレームワークのコンテナ化とアップグレード戦略
shunta27
0
310
PHPのバージョンアップ時にも役立ったAST
matsuo_atsushi
0
230
React 19アップデートのために必要なこと
uhyo
8
1.5k
ソフトウェアエンジニアの成長
masuda220
PRO
12
2.1k
良いコードレビューとは
danimal141
5
1k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
69
4.5k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.2k
Unsuck your backbone
ammeep
669
57k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Side Projects
sachag
452
42k
Producing Creativity
orderedlist
PRO
344
40k
For a Future-Friendly Web
brad_frost
176
9.6k
Scaling GitHub
holman
459
140k
Rails Girls Zürich Keynote
gr2m
94
13k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Transcript
Spring Data Repositories A Deep Dive Oliver Gierke
Oliver Gierke Spring Data engineer Core / JPA / Mongo
JPA Expert Group
[email protected]
www.olivergierke.de olivergierke
Hands on
Sample code https://github.com/olivergierke/ repositories-deepdive
Step 0 Initial project setup
Summary Use kickstart projects to ease setup
Step 1 Basic JPA infrastructure setup
"Persistence technology of choice is JPA. e application uses JavaConfig
and sample data contained in data.sql.
Summary Easy setup through JavaConfig XML-less JPA configuration
Step 2 Quickstart
"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.
Summary Interface-based programming model No implementation required Queries derived from
method names
Step 3 Extended CRUD methods
" Customers can be deleted and obtained all at once.
Summary Switched to CrudRepository Exposed CRUD methods Broad API exposed
Step 4 Pagination
"Customers can be accessed page by page.
Summary Switched to PagingAndSortingRepository Exposed CRUD methods and paging ones
Broad API exposed
Step 5 Re-declaring existing CRUD methods
"CustomerRepository.findAll() should rather return a List. e transaction timeout for
save(…) should be customized to 10 seconds.
Summary Re-declare methods to customize Return types Annotation config (Tx,
Locking)
Step 6 Introducing a read-only repository base interface
"Products shall be accessible in read-only mode only.
Summary Craft custom base interface Annotation config (Tx, Locking)
Step 7 Using manually defined queries
"As a user, I want to look up products by
their custom attributes.
Summary @Query annotation JPA named queries Spring Data named queries
Step 8 Flexible predicate execution
"As a user, I want to search for customers by
firstname, lastname, email address and any combination of them
Summary Querydsl - type safe queries for Java QuerydslPredicateExecutor
Side track: Repository proxies
Proxy mechanism Using Spring's JDK proxy support Bootstrap through Factory
Spring FactroyBean / CDI XML namespace / @EnableRepositories
Proxy mechanism Query interface CRUD implementation class QueryDslPredicateExecutor Custom implementation
extension
Step 9 Custom implementations for repositories
"As an admin user, I'd like to delete all products
beyond a given price.
Summary Provide custom implementation Base class support (Querydsl)
Stuff on top Spring MVC integration Spring Data REST Spring
Roo
Up and beyond
Supported modules JPA MongoDB Neo4j Gemfire
Community implementations Spring Data Solr Couchbase Elasticsearch FuzzyDB
Summary
Interface-based programming model
Start simple, get more sophisticated
Declarative query execution
Flexible predicate execution
Custom implementation
CDI integration
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 Gemfire Splunk
Spring Data Book http://bit.ly/sd-book
Questions?
Thank you!
Code https://github.com/olivergierke/ repositories-deepdive https://github.com/olivergierke/ spring-restbucks