what's new in spring data
DESCRIPTION
Speakers: Thomas Darimont, Oliver Gierke, Christoph Strobl Data / Integration Track This talk will give a broad overview of the new features introduced in the latest Spring Data release trains. We will cover recent additions and improvements in Spring Data Commons - the module that's shared amongst the store specific ones. We'll then delve into the latest and greatest features of individual store modules, like JPA, MongoDB, Neo4j, Solr and the community ones as well.TRANSCRIPT
![Page 1: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/1.jpg)
© 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.
What’s new in Spring Data?Oliver Gierke - Thomas Darimont - Christoph Strobl
![Page 2: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/2.jpg)
Agenda
Overview Repositories
Store modules Q&A
![Page 3: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/3.jpg)
Release train
![Page 4: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/4.jpg)
!• Release coordination effort make sure modules are compatible
• Reduce different versions into a single canonical name to refer to
Release train
03/2013
Arora
09/2013
Babbage
02/2014
Codd
05/2014
Dijkstra
09/2014
Evans
![Page 5: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/5.jpg)
Spring Data Modules
Core
Neo4j Gemfire
JPA
Solr
Elasticsearch
REST
CassandraCouchbase
Redis
MongoDB
Communitymodules
Coremodules
![Page 6: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/6.jpg)
Module setup - Codd
Core
Neo4j Gemfire
JPA
Solr
Elasticsearch
REST
CassandraCouchbase
Redis
MongoDB
Communitymodules
Coremodules
![Page 7: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/7.jpg)
Module setup - Dijkstra / Evans
Core
Neo4j Gemfire
JPA
Solr
Elasticsearch
REST
CassandraCouchbase
Redis
MongoDB
Communitymodules
Coremodules
![Page 8: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/8.jpg)
Evans GA!Hooray! \o/
![Page 9: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/9.jpg)
![Page 10: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/10.jpg)
Spring Data Evans - Major themes
• Upgrade to Spring 4.0
• Support for top/first keywords in derived queries
• Support for MongoDB 2.6 features like text search
• SpEL support for Spring Data JPA (Spring Security integration)
• Redis Sentinel support
• ALPS and excerpt projections for Spring Data REST
• Improved multi-store configuration
• Asciidoctor for reference documentation
![Page 11: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/11.jpg)
Spring DataRepositories
Pragmatic data access APIs
![Page 12: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/12.jpg)
Multi-storeconfiguration
We know what you were thinking!
![Page 13: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/13.jpg)
Improved multi-store configuration
!• Triggered if multiple Spring Data modules are detected
• Modules only register for interfaces that a assigned to the store • Annotations on domain types (@Entity, @Document) • Store specific repository base interface (not recommended)
![Page 14: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/14.jpg)
Debug output
… DEBUG … - Multiple Spring Data modules found, entering strict repository configuration mode! !… DEBUG … - Spring Data JPA - Could not safely identify store assignment for repository candidate interface ….OrderRepository. !… DEBUG … - Spring Data JPA - Registering repository: Interface: ….CustomerRepository Factory: ….JpaRepositoryFactoryBean
![Page 15: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/15.jpg)
Query methods
![Page 16: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/16.jpg)
SlicesPaging without the overhead
![Page 17: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/17.jpg)
Slices
!• Pagination
• Additional query to calculate the total number of elements !
• Slices • Reads one more element than necessary to find out about presence of next slice (optional)
• Store-specific optimization
![Page 18: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/18.jpg)
(Optional) supportNo more NullPointerExceptions with Java 8 or Guava
![Page 19: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/19.jpg)
Default methods
![Page 20: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/20.jpg)
Slices and Optional example
interface SampleRepository implements Repository<User, Long> { Slice<User> findByLastname(String lastname, Pageable page); ! Optional<User> findByEmailAddress(EmailAddress email); ! Optional<User> findByLastname(String lastname); ! default Optional<Customer> findByLastname(Customer c) { return findByLastname(c == null ? null : c.lastname); } }
![Page 21: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/21.jpg)
Limiting result setsYou’r only interested in the top ones anyway, right?
![Page 22: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/22.jpg)
Limiting result sets
!• Previous options
• Use Pageable/Page to dynamically restrict results
• Additional keywords to statically restrict results
interface SampleRepository implements Repository<User, Long> { List<User> findTop10ByNameLike(String name, Sort sort); }
![Page 23: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/23.jpg)
Deriveddelete queries
![Page 24: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/24.jpg)
Demo
![Page 25: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/25.jpg)
Miscellaneous
![Page 26: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/26.jpg)
CDI improvementsEager instantiation and custom implementations
![Page 27: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/27.jpg)
Commongeo-spatial types
![Page 28: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/28.jpg)
NullsFirst /NullsLast
![Page 29: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/29.jpg)
Store moduleimprovements
![Page 30: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/30.jpg)
JPAJava Persistence API 2.1 support
![Page 31: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/31.jpg)
JPA Improvements
!• JPA 2.1 support
• Execution of stored procedures • Support for entity graph definitions !
• Integration with Spring Security • Out of the box support coming with Spring Security 4.1
![Page 32: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/32.jpg)
Demo
![Page 33: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/33.jpg)
MongoDB
![Page 34: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/34.jpg)
Aggregationgo on with system variables
![Page 35: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/35.jpg)
Aggregation Framework
!• System Variables
• $$ROOT
• $$CURRENT
Aggregation aggregation = Aggregation.newAggregation( group(„foo"). push(Aggregation.ROOT).as("users"));
![Page 36: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/36.jpg)
Query ModifiersAlter query behavior
![Page 37: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/37.jpg)
Query Modifiers
• Define output and behavior of query
• $comment
• $maxTimeMS
• …
interface SampleRepository implements Repository<User, Long> { @Meta(comment=“s2gx2014”) List<User> findByFirstname(String firstname); }
![Page 38: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/38.jpg)
Full $text searchSimple - Powerful - Easy
![Page 39: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/39.jpg)
Text Search
!• Supported since MongoDB 2.6
• Multiple stemmers
• Different languages
interface SampleRepository implements Repository<User, Long> { List<User> findAllBy(TextCriteria criteria); }
![Page 40: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/40.jpg)
Redis
![Page 41: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/41.jpg)
SCANThe non-blocking alternative
![Page 42: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/42.jpg)
SCAN Support
• Non-blocking alternative
• KEYS
• SMEMBERS
Cursor<String> keys = redisConnection.scan(); !while(cursor.hasNext()) { cursor.next(); }
![Page 43: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/43.jpg)
SentinelMonitoring & failover for your cluster
![Page 44: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/44.jpg)
Sentinel Support
!• Monitoring and failover
• Currently only available using Jedis
@Bean public RedisSentinelConfiguration sentinelConfig() { return new RedisSentinelConfiguration().master("mymaster") .sentinel("localhost", 26379) .sentinel("localhost", 26380); }
![Page 45: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/45.jpg)
Sentinel support
Redis
![Page 46: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/46.jpg)
Sentinel support
Redis Redis Redis
![Page 47: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/47.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 48: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/48.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 49: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/49.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 50: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/50.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 51: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/51.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 52: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/52.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 53: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/53.jpg)
Sentinel support
Redis Redis Redis
Sentinel Sentinel Sentinel
![Page 54: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/54.jpg)
Solr
![Page 55: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/55.jpg)
Deep paginationGo deep at top speed
![Page 56: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/56.jpg)
Deep pagination
!• Performance boost when going deep
• Uses cursor
Cursor<User> cursor = template.queryForCursor(q, User.class); !while(cursor.hasNext()) { User user = cursor.next(); }
![Page 57: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/57.jpg)
Schema SupportClient side schema management
![Page 58: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/58.jpg)
Schema Support
!• Usage of Schema Solr REST API
• Add new fields to existing schema.
@Configuration @EnableSolrRepositories(schemaCreationSupport = true) class SolrConfiguration { !}
![Page 59: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/59.jpg)
Spring Data REST
![Page 60: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/60.jpg)
Spring Data REST
• Implements common patterns on top of repositories • Collection / item resources • Association resources • Search resources
• Leverages hypermedia and internet standards • URI Templates (RFC 6570) • application/hal+json • text/uri-list (RFC 2483) • profile link relation (RFC 6906)
![Page 61: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/61.jpg)
ALPS support & excerpt projections
!• Application Level Profile Semantics
• Spring Data REST exposes resources describing the service
!• Interface-based programming model to define custom projections
• Configuration to define excerpt projections
![Page 62: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/62.jpg)
Demo
![Page 63: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/63.jpg)
Related talks
![Page 64: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/64.jpg)
Spring Data Related Talks
• Cassandra / Couchbase - Tue, 4:30 pm • Cassandra, Couchbase and Spring Data in the Enterprise
• Spring Data BOF - Tue, 9:00 pm
• REST - Wed, 8:30 am • Spring Data REST - Data Meets Hypermedia
• Neo4j - Wed, 10:30 am • Artistic Spring Data Neo4j 3.0 with Spring Boot and Van Goch
• GORM - Wed, 12:45 pm • Advanced GORM – Beyond Relational
![Page 65: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/65.jpg)
Sample codehttps://github.com/SpringOne2GX-2014/whats-new-in-spring-data
![Page 66: What's new in spring data](https://reader033.vdocuments.us/reader033/viewer/2022042700/557d5f2bd8b42abf3d8b4fe3/html5/thumbnails/66.jpg)
Questions?