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
March 14, 2013
Programming
3
640
Spring Data Repositories - A Deep Dive
Slides of my talk on Spring Data repositories at 33degree conference in Warszaw, Poland.
Oliver Drotbohm
March 14, 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
4
410
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
590
Spring Modulith – A Deep Dive
olivergierke
7
3.7k
Spring for the Architecturally Curious Developer
olivergierke
5
1.7k
Spring Boot 3 & Spring Framework 6
olivergierke
4
1.9k
Architecturally-evident Java Applications with jMolecules
olivergierke
8
2.6k
A Deep Dive into Spring Application Events
olivergierke
12
3.1k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
870
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
640
Other Decks in Programming
See All in Programming
いかにして不足・不整合なくデータ移行したか
tjmtmmnk
1
910
Piniaの現状と今後
waka292
2
520
Golang と Erlang
taiyow
7
1.8k
LangChain & LangServeでAPIを爆速作成
kijitorabuti
2
360
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
0
440
レガシーな Android アプリのリアーキテクチャ戦略
oidy
1
160
学生の時に開催したPerl入学式をきっかけにエンジニアが組織に馴染むために勉強会を主催や仲間と参加して職能間の境界を越えていく
ohmori_yusuke
2
330
How to debug Xdebug... or any other weird bug in PHP
dunglas
2
1.5k
sqlcを利用してsqlに型付けを
kamiyam
0
250
Google Play Consoleデベロッパー アカウントの確認 / Verifying your Play Console developer account
kubode
0
310
実践サーバーレスパフォーマンスチューニング ~その実力に迫る~ / Practical Serverless Performance Tuning ~A Close Look at its Power~
seike460
PRO
2
230
フロントエンドの現在地とこれから
koba04
10
4.7k
Featured
See All Featured
Designing for humans not robots
tammielis
249
25k
The Pragmatic Product Professional
lauravandoore
31
6.2k
GraphQLの誤解/rethinking-graphql
sonatard
66
9.9k
Producing Creativity
orderedlist
PRO
341
39k
Practical Orchestrator
shlominoach
186
10k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
46
2.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
5
130
What's in a price? How to price your products and services
michaelherold
243
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
Done Done
chrislema
181
16k
Build The Right Thing And Hit Your Dates
maggiecrowley
32
2.3k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.6k
Transcript
Spring Data Repositories A Deep Dive Oliver Gierke
Oliver Gierke SpringSource Spring Data modules Core / JPA /
Mongo
[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 Return types 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 Free JPA chapter - http://bit.ly/sd-book-chapter
Spring Data Book http://bit.ly/sd-book
Questions?
Thank you!
Code https://github.com/olivergierke/ repositories-deepdive https://github.com/olivergierke/ spring-restbucks