Slide 1

Slide 1 text

Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction to Spring Data Greg Turnquist @gregturn github.com/gregturn

Slide 2

Slide 2 text

GregLTurnquist.com/list

Slide 3

Slide 3 text

GregLTurnquist.com/list

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

We’re hiring! (Atlanta + the world) http://pivotal.io/careers

Slide 6

Slide 6 text

It’s 2016

Slide 7

Slide 7 text

It’s 2016 Why are we still writing…

Slide 8

Slide 8 text

It’s 2016 Why are we still writing… select * from EMPLOYEE where FIRST_NAME = %1

Slide 9

Slide 9 text

It’s 2016 Why are we still writing… select * from EMPLOYEE where FIRST_NAME = %1 select e from Employee e where e.firstName = :name

Slide 10

Slide 10 text

It’s 2016 Why are we still writing… select * from EMPLOYEE where FIRST_NAME = %1 select e from Employee e where e.firstName = :name create .select() .from(EMPLOYEE) .where(EMPLOYEE.FIRST_NAME .equal(name)) .fetch()

Slide 11

Slide 11 text

It’s 2016 Why are we still writing… select * from EMPLOYEE where FIRST_NAME = %1 select e from Employee e where e.firstName = :name create .select() .from(EMPLOYEE) .where(EMPLOYEE.FIRST_NAME .equal(name)) .fetch() SQL JPA jOOQ

Slide 12

Slide 12 text

When we could write…

Slide 13

Slide 13 text

When we could write… save(), findOne(), findAll() exists(), delete(), and count() …includes

Slide 14

Slide 14 text

10+ years ago SQL

Slide 15

Slide 15 text

Today SQL NoSQL

Slide 16

Slide 16 text

Today SQL NoSQL Cypher MongoDB CLI CQL OQL EJBQL HQL N1QL

Slide 17

Slide 17 text

Spring Data provides… relational non-relational abstraction JDBC

Slide 18

Slide 18 text

Spring Data provides… relational non-relational Elastic Solr Neo4j Cassandra MongoDB Gemfire Redis Couchbase abstraction JDBC

Slide 19

Slide 19 text

Spring Data provides… relational non-relational Elastic Solr Neo4j Cassandra MongoDB Gemfire Redis Couchbase abstraction JDBC JPA

Slide 20

Slide 20 text

Spring Data provides… relational non-relational Spring Data Elastic Solr Neo4j Cassandra MongoDB Gemfire Redis Couchbase abstraction JDBC JPA

Slide 21

Slide 21 text

Spring Data provides… relational non-relational Spring Data Elastic Solr Neo4j Cassandra MongoDB Gemfire Redis Couchbase abstraction JDBC JPA Reactive support coming soon!

Slide 22

Slide 22 text

Dialing it up interface EmployeeRepository extends CrudRepository { List findByLastName(String f) List findByFirstNameAndLastName(String f, String l) List findByFirstNameAndManagerName(String f, String m) List findTop10ByFirstName(…) // or findFirst10ByFirstName List findDistinctEmployeesByFirstName(...) List findByFirstNameAndLastNameAllIgnoreCase(...) List findByFirstNameOrderByLastNameAsc(...) List findByLastNameIsNull(...) }

Slide 23

Slide 23 text

Why stop there? interface CoolRepo extends CrudRepository { Stream findByLastname(String lastname) @Async Future findByLastname(…) @Async CompletableFuture findByLastname(…) @Async ListenableFuture findByLastname(…) Page findAll(Pageable p) Page findByFirstName(String f, Pageable p) List findAll(Sort s) Page findByFirstName(String f, Pageable p, Sort s) }

Slide 24

Slide 24 text

Why stop there? interface CoolRepo extends CrudRepository { Stream findByLastname(String lastname) @Async Future findByLastname(…) @Async CompletableFuture findByLastname(…) @Async ListenableFuture findByLastname(…) Page findAll(Pageable p) Page findByFirstName(String f, Pageable p) List findAll(Sort s) Page findByFirstName(String f, Pageable p, Sort s) } Use @Query to write custom queries

Slide 25

Slide 25 text

Demo Unless otherwise indicated, these slides are 
 © 2013-2014 Pivotal Software, Inc. and licensed under a Creative Commons Attribution- NonCommercial license: http:// creativecommons.org/licenses/by-nc/3.0/ Spring Data

Slide 26

Slide 26 text

Links • http://projects.spring.io/spring-data • https://github.com/spring-projects/spring-data- examples • https://spring.io/guides/tutorials/react-and-spring- data-rest/ • https://spring.io/guides?filter=spring%20data

Slide 27

Slide 27 text

Unless otherwise indicated, these slides are © 2013-2014 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction to Spring Data Greg Turnquist @gregturn github.com/gregturn