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
590
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
Spring Modulith – A Deep Dive
olivergierke
7
1.8k
Spring for the Architecturally Curious Developer
olivergierke
5
1.6k
Spring Boot 3 & Spring Framework 6
olivergierke
4
1.8k
Architecturally-evident Java Applications with jMolecules
olivergierke
8
2.4k
A Deep Dive into Spring Application Events
olivergierke
12
2.8k
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
4
820
Spring HATEOAS – Hypermedia APIs with Spring
olivergierke
1
560
Building Better Monoliths – Modulithic Applications with Spring Boot
olivergierke
6
3.8k
REST Beyond the Obvious – API Design for Ever Evolving Systems
olivergierke
5
1.1k
Other Decks in Programming
See All in Programming
CircleCIを活用して AWSへの継続的デリバリーを 実践する
coconala_engineer
1
230
1인 개발자로 행복하게 살기 - GDG 송도 헬로월드 2024
benjaminkim
1
5.6k
Rubyでたのしむクリエイティブコーディング/Enjoy Creative coding with Ruby
chobishiba
1
160
CQRS/ES avec Symfony, c’est (trop) bien !
jeremyfreeagent
1
630
object-oriented-conference-2024
fuwasegu
8
2.7k
Elm 0.19.0 Changes
bkuhlmann
0
480
Elm Form Validation
bkuhlmann
0
500
デザインシステムで Tailwind CSSとCSS in JSに分散投資をしたら良かった話
fsubal
18
4.8k
ゆるい個人開発のススメ
kuroppe1819
10
920
ログラスを支える設計標準について / loglass-design-standards
urmot
10
2.1k
9年開発を牽引して見えてきた、共通化すべきものと個別でつくるもの ~プログラム言語~
shinout
1
640
⼤規模⾔語モデルの拡張(RAG)が 終わったかも知れない件について
nearme_tech
22
15k
Featured
See All Featured
How To Stay Up To Date on Web Technology
chriscoyier
781
250k
Building Applications with DynamoDB
mza
88
5.6k
Why Our Code Smells
bkeepers
PRO
331
56k
What's new in Ruby 2.0
geeforr
336
31k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
Making the Leap to Tech Lead
cromwellryan
123
8.5k
jQuery: Nuts, Bolts and Bling
dougneiner
59
7.1k
Web development in the modern age
philhawksworth
201
10k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
243
20k
4 Signs Your Business is Dying
shpigford
175
21k
Building a Scalable Design System with Sketch
lauravandoore
455
32k
Art, The Web, and Tiny UX
lynnandtonic
288
19k
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