Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Spring Data Repositories - A Deep Dive
Oliver Drotbohm
April 04, 2013
Programming
4
100
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
Architecturally-evident Java Applications with jMolecules
olivergierke
6
1.3k
A Deep Dive into Spring Application Events
olivergierke
10
1.8k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
540
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
0
320
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
6
3k
REST Beyond the Obvious – API Design for Ever Evolving Systems
olivergierke
5
1.1k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
11
3.5k
REST Beyond the Obvious – API design for ever evolving systems
olivergierke
27
4.3k
Spring Framework 5 & Spring Boot 2.0
olivergierke
14
1.5k
Other Decks in Programming
See All in Programming
Yumemi.apk #6 ~ゆめみのAndroidエンジニア 日頃の成果大発表会!~ Session 2
blendthink
1
210
mrubyを1300円のボードで動かそう
yuuu
0
180
Kotlin 最新動向2022 #tfcon #techfeed
ntaro
1
1.1k
Node.js 最新動向 TFCon 2022
yosuke_furukawa
PRO
6
2.8k
インフラエンジニアの多様性と評価、またはキャリアへのつなげ方 / Careers as infrastructure engineers
katsuhisa91
0
500
Is Rust a great language for building Kubernetes ecosystem
deepu105
0
140
Hapticをカスタマイズしてみよう / ZOZO Tech Talk #6 Customize Haptic
endoumari
0
290
WindowsコンテナDojo : 第1回 Visual StudioでWindowsコンテナアプリ作成
oniak3ibm
PRO
0
330
Microsoft Teams の 会議アプリ開発のはじめかた / How to start Microsoft Teams app development
karamem0
0
1.6k
機能横断型チームにおける技術改善
takeshiakutsu
3
450
あなたの会社の古いシステム、なんとかしませんか?~システム刷新から考えるDX化への道筋とバリエーション~/webinar20220420-systems
grapecity_dev
0
130
Enterprise Angular: Frontend Moduliths with Nx and Standalone Components @jax2022
manfredsteyer
PRO
0
300
Featured
See All Featured
Build your cross-platform service in a week with App Engine
jlugia
219
17k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
237
19k
The Art of Programming - Codeland 2020
erikaheidi
31
5.8k
Code Review Best Practice
trishagee
41
6.7k
Building Applications with DynamoDB
mza
83
4.6k
Adopting Sorbet at Scale
ufuk
63
7.5k
Producing Creativity
orderedlist
PRO
333
37k
Testing 201, or: Great Expectations
jmmastey
21
5.4k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
212
20k
Pencils Down: Stop Designing & Start Developing
hursman
112
9.8k
Become a Pro
speakerdeck
PRO
3
780
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
100
5.9k
Transcript
Spring Data Repositories A Deep Dive Oliver Gierke
Oliver Gierke Spring Data engineer Core / JPA / Mongo
JPA Expert Group ogierke@vmware.com 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