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
4
450
Bottom-Up Architecture – Bridging the Achitecture Code Gap
olivergierke
4
730
Spring Modulith – A Deep Dive
olivergierke
7
3.8k
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.7k
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
650
Other Decks in Programming
See All in Programming
イベント駆動で成長して委員会
happymana
1
320
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
RubyLSPのマルチバイト文字対応
notfounds
0
120
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
シールドクラスをはじめよう / Getting Started with Sealed Classes
mackey0225
4
640
macOS でできる リアルタイム動画像処理
biacco42
9
2.4k
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Macとオーディオ再生 2024/11/02
yusukeito
0
370
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Featured
See All Featured
Happy Clients
brianwarren
98
6.7k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Gamification - CAS2011
davidbonilla
80
5k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
Building Your Own Lightsaber
phodgson
103
6.1k
Thoughts on Productivity
jonyablonski
67
4.3k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
The World Runs on Bad Software
bkeepers
PRO
65
11k
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