Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ What’s New in Spring Data? Mark Paluch • Christoph Strobl @mp911de • @stroblchristoph
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Agenda 3 Overview Core Themes Store modules Q&A
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Hopper Release 4 image source: https://commons.wikimedia.org (License: CC0)
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Release train BOM 5 <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-releasetrain</artifactId> <version>Hopper-SR2</version> <scope>import</scope> <type>pom</type> </dependency>
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Release train - Spring Framework baselines 7 Dijkstra May 2014 Spring 3.2 Evans August 2015 Spring 4.0 Fowler March 2015 Spring 4.0 Gosling September 2015 Spring 4.1 Hopper April 2016 Spring 4.2 Ingalls* 2016 Spring 4.2
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Major Dependency upgrades for Hopper • Upgraded Spring Framework baseline to 4.2 • Upgrade to Querydsl 4 • Upgrade to Elasticsearch 2.0 • Upgrade to Solr 5 8
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Query by Example • Value objects provided by Spring Data Commons • Supported by Spring Data JPA and Spring Data MongoDB 10 Example<User> example = Example.of( " " " ); " " repository.findAll(example); new User("jon", "snow"), ExampleMatcher.matching() .withMatcher("lastname", matcher -> matcher.ignoreCase().startsWith())
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Projections in Repository Query Methods • First time seen with Evans in Spring Data REST • Projections to reduce or enhance view of resources 12 interface CustomerProjection { " String getFirstname(); " } interface CustomerSummary { " @Value( "#{target.firstname + ' ' + target.lastname}") String getFullName(); @Value("#{@mybean.someMethod(target)}") String getSomeCalculatedValue(); " } Closed Projection Open Projection
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Commons • Support for Composed Annotations • Support JDK 8 and Guava Optional on repository query parameters • Allow aliasing of Querydsl web bindings • Converter support for JSR-310's ZoneId. 14
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 15 Demo Composed Annotations
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 16 Demo Wrapped Parameters
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Redis " • Deprecated jredis and srp drivers • Redis Cluster support (Jedis & Lettuce) • Support for object mapping and repositories • Redis SSL support 18
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire • Support for OQL specific features via Annotations • @Trace • @Limit 22 • Annotation based eviction strategies • @TimeToLiveExpiration • @IdleTimeout interface UserRepository extends GemfireRepository { @Trace @Limit(5) @Hint("UsernameIdx") List<User> findByUsernameLike(String username); } @TimeToLiveExpiration( timeout="300", action="LOCAL_DESTROY") @IdleTimeoutExpiration( timeout="120", action="LOCAL_INVALIDATE") class DomainObject { //… }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Couchbase • N1QL Integration. • SQL extension for JSON. • Allows sorting and Paging. • Evaluates your SpEL expressions and named parameters. 23 • Geospatial query support via specialized Views • Support for auditing annotations. interface PartyRepository extends Repository<Party, String> { @Dimensional( designDocument="partyGeo", spatialViewName="byLocation") List<Party> findByLocNear(Point p, Distance d); } interface UserRepository extends Repository<User, String> { " List<User> findByUsernameContains(String s); @Query List<User> findByAgeBetween(int min, int max); }
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Elasticsearch • Upgrade to Elasticsearch 2 • Removed Facet feature -> Please use Aggregations instead. 24
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Outlook - Ingalls 25 image source: https://commons.wikimedia.org (License: CC0 BY-SA 3.0)
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Outlook • Upgrade to Cassandra 3.0 " • Performance improvements • General: Method handles for property access in object mapping. • MongoDB: DBRef loading improvements. • Couchbase: Async API usage for view based queries. • Redis • Partial updates in Redis repositories. • Support for GEO commands and derived findBy…Near/Within queries. " • MongoDB • Aggregation Framework improvements. • $min / $max support in MongoDB. • REST: • Support for inbound projections using JSONPath / XPath (via XMLBeam). • Support for VND Error and RFC7807 (Problem details for HTTP APIs). • Support for additional hypermedia formats (Siren, Affordances). 28
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Oh, wait - one more thing 29
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ ..maybe you’ve heard of Reactive Programming 30
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data 2.0 • Upgrade JDK baseline to 8 • Upgrade Spring Framework baseline to 5.0 • Reactive support for MongoDB, Redis and Couchbase • Store implementations using either RxJava or Project Reactor • Reactive wrapper type conversion on Repository level 31 ! STAY TUNED !
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 32 Demo Reactive Data Access
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Related Sessions • Tue, 2nd, August, 2016 • 3:20 pm – Christoph Strobl Spring Data Redis Cluster & Repositories " • Wed, 3rd, August, 2016 • 2:00 pm – Sébastien Deleuze, Stéphane Maldini A Lite Rx API for the JVM • Wed, 3rd, August, 2016 • 3:20 pm – John Blum, Mark Paluch Outlook: Spring Data Cassandra 1.5 33
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Related Sessions • Thu, 4th, August, 2016 • 9:00 am – John Blum, Luke Shannon Spring Data and In-Memory Data Management in Action " • Thu, 4th, August, 2016 • 11:10 am – Oliver Gierke Advanced Spring Data REST " • Thu, 4th, August, 2016 • 11:45 am – Viktor Gamov, Neil Stevenson Spring Data Hazelcast: Fluently Accessing Distributed Repositories 34
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Resources • Slides – TBA • Spring Data Examples – Repository @ Github • Spring Data wiki (Release trains, planning) – Wiki • Spring projects release calendar – Google Calendar " • Chat with us on Gitter! 36
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Learn More. Stay Connected. Follow us @SpringData @springcentral spring.io/blog @pivotal pivotal.io/blog @pivotalcf http://engineering.pivotal.io Talk to us spring-projects/spring-data
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Safe Harbor Statement • The following is intended to outline the general direction of Pivotal's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of Pivotal offerings, future updates or other planned modifications is subject to ongoing evaluation by Pivotal and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding Pivotal's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for Pivotal's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 38