Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Spring Data

1,164 views

Published on

SpringOne Platform 2016
Speaker: Greg Turnquist; Spring Team Member, Pivotal

It’s 2016. Are you still writing data queries by hand? Learn how Spring Data gives you the tools to leap over that hurdle and dive into solving problems. Feeling locked into your relational database due to having written gobs of SQL operations? In this live coding session, see how Spring Data provides the means to reduce that risk and give you the means to branch into other data stores. With a couple extra lines of code, you can even have a RESTful interface in no time flat.

Published in: Technology
  • Be the first to comment

Introduction to Spring Data

  1. 1. Unless otherwise indicated, these slides are © 2013-2016 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
  2. 2. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Who am I? 2 GregLTurnquist.com/learning-spring-boot
  3. 3. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It’s 2016 3
  4. 4. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ It’s 2016 4 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
  5. 5. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ When we could write… 5
  6. 6. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data provides… 6 relational non-relational Spring Data Elastic Solr Neo4jCassandra MongoDB GemfireRedis Couchbase abstraction JDBC JPA
  7. 7. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Dialing it up 7 interface EmployeeRepository extends CrudRepository<Employee, Long> { List<Employee> findByLastName(String f) List<Employee> findByFirstNameAndLastName(String f, String l) List<Employee> findByFirstNameAndManagerName(String f, String m) List<Employee> findTop10ByFirstName(…) // or findFirst10ByFirstName List<Employee> findDistinctEmployeesByFirstName(...) List<Employee> findByFirstNameAndLastNameAllIgnoreCase(...) List<Employee> findByFirstNameOrderByLastNameAsc(...) List<Employee> findByLastNameIsNull(...) }
  8. 8. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Why stop there? 8 interface CoolRepo extends CrudRepository<Employee, Long> { Stream<Employee> findByLastname(String lastname) @Async Future<Employee> findByLastname(…) @Async CompletableFuture<Employee> findByLastname(…) @Async ListenableFuture<Employee> findByLastname(…) Page<Employee> findAll(Pageable p) Page<Employee> findByFirstName(String f, Pageable p) List<Employee> findAll(Sort s) Page<Employee> findByFirstName(String f, Pageable p, Sort s) }
  9. 9. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Coming soon… 9 interface ReactiveStreamsRepo extends CrudRepository<Employee, Long> { Mono<Employee> findByLastname(String lastname) Flux<Employee> findByLastname(…) } Integration with Spring 5 + Project Reactor
  10. 10. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Demo
  11. 11. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Introduction to Spring Data Visit spring.io/guides, type “data”, and enjoy! See all talks by Oliver Gierke, Christoph Stroble, Mark Paluch, & John Blum and Spinnaker: Land of a 1000 Builds - later today @ 5pm @springcentral spring.io/blog @pivotal pivotal.io/blog @pivotalcf http://engineering.pivotal.io

×