Slide 1

Slide 1 text

Spring Data Cookbook Delicious Recipes for Fast, Secure Data INGREDIENTS - 8 c Innovation - 2 tsp DDD - 5 Repository Interfaces - 12 Store Modules - a pinch of devs 2024 Edition - Christoph Strobl Image by: private photo

Slide 2

Slide 2 text

Studying younger me Eating habits Evolution Image by: private photos

Slide 3

Slide 3 text

Image by: private photo The ambition of every good cook
 must be to make something 
 very good
 with the fewest possible 
 ingredients. Urbain Dubois
 French chef (1818-1901) Preface

Slide 4

Slide 4 text

The SD Domain Image source: Microsoft Stock Photos A type holding user de fi ned information within a given scope / problem space. Domain Type An extension to a repository that provides additional domain speci fi c functionality. Custom Implementation An isolated view based on an aggregate root. Projection Low level API managing resources and transaction boundaries. Template Interface to access persistent collections of aggregate roots. Repository A cluster of domain types that can be treated as a single unit. Aggregate Root

Slide 5

Slide 5 text

Equalicense CC0 Image source: Microsoft Stock Photos Pancakes INGREDIENTS - Packages & Visibility - Domain Types - Repository Interface Topping: - Executor Addons - Custom Implementations

Slide 6

Slide 6 text

Order Order, LineItem, … OrderRepository OrderManagement

Slide 7

Slide 7 text

Order Order, LineItem, … OrderRepository OrderManagement Repository PagingAndSortingRepository CrudRepository ListCrudRepository ListPagingAndSortingRepository JpaRepository (Try to) Avoid leaking store speci fi cs like entityManager. fl ush() into your repository.

Slide 8

Slide 8 text

Order Order, LineItem, … OrderRepository OrderManagement

Slide 9

Slide 9 text

Order Order, LineItem, … OrderRepository OrderManagement

Slide 10

Slide 10 text

Order Order, LineItem, … OrderRepository OrderManagement

Slide 11

Slide 11 text

Dips INGREDIENTS - Various Annotations Image source: Microsoft Stock Photos

Slide 12

Slide 12 text

common to many repositories in domain Base Repo Salsa

Slide 13

Slide 13 text

Base Repo Salsa Variant 1: Variant 2:

Slide 14

Slide 14 text

Annotation Sauce JPA Flavoured Try store speci fi c fl avours. Each one o ff ers a unique taste.

Slide 15

Slide 15 text

Image source: Microsoft Stock Photos BBQ Skewers INGREDIENTS - Packages & Visibility - Domain Types - Repository Interface Topping: - Prede fi ned Layout - Executor Addons - Custom Implementations Image source: Microsoft Stock Photos INGREDIENTS - Collections - Streams - Slice & Pages - Windows Variations: - Reactive - Async

Slide 16

Slide 16 text

Iterable Skewer List Skewer Stream Skewer selected DB fl avours only

Slide 17

Slide 17 text

Slice Skewer hasNext Page Skewer hasNext
 totalCount

Slide 18

Slide 18 text

Window Skewer selected DB fl avours only o ff set skip limit keyset position limit hasNext

Slide 19

Slide 19 text

Iterable List Stream Slice Page Window Flux size total next data
 loaded count
 query scroll
 strategy n n n+1 n+1 n driver request o ff set o ff set o ff set o ff set o ff set o ff set keyset / o ff set n n n n n n y

Slide 20

Slide 20 text

Red Beans Burger INGREDIENTS - Projections - Entity Converters - Property Converters Image source: Microsoft Stock Photos

Slide 21

Slide 21 text

Closed Projection Interface DTO

Slide 22

Slide 22 text

Open Projection Closed Projections are backed by Maps holding only the required subset of fi elds required to render the view. Open Projections are backed by the entire target domain type loaded into memory.

Slide 23

Slide 23 text

Custom Conversion selected DB fl avours only Entity Converter

Slide 24

Slide 24 text

Custom Conversion selected DB fl avours only Property Converter You can also register converter as beans
 to leverage the full application context.

Slide 25

Slide 25 text

Image source: Microsoft Stock Photos Data Curry INGREDIENTS - Type safe Queries - Fluent Queries

Slide 26

Slide 26 text

Model QBE Querydsl Typesafe Queries

Slide 27

Slide 27 text

Fluent Queries

Slide 28

Slide 28 text

Image source: Microsoft Stock Photos Sides INGREDIENTS - Environment Variables - Null Handling

Slide 29

Slide 29 text

null -> EmptyResultDataAccessException null Order#34 Nullability Annotations leverage 
 JSR-305 meta-annotations 
 to indicate nullability to tools 
 and Kotlin. jsr 305 placeholder

Slide 30

Slide 30 text

Core Temperature - Observability - Alternative Runtimes

Slide 31

Slide 31 text

Runtimes Considerations GraalVM CRaC CDS Closed World Compatibility Built Time Fixed Bean Conditions
 No dynamic class loading Additional Metadata for
 re fl ection, proxies,… Checkpoint
 startup Need to start 
 the App ahead
 Lifecycle
 management Need to close/reopen
 sockets, fi les, … Secret
 management Sensitive information 
 may be leaked System
 Integration Linux only Training
 run Need to start 
 the App ahead
 Lifecycle
 management Lazy resource 
 connect takes longer

Slide 32

Slide 32 text

Micrometer JFR Insights

Slide 33

Slide 33 text

Acknowledgements …and many, many more! Image source: private photos & github