SlideShare a Scribd company logo
An Introduction to Spring Data

Oliver Gierke - SpringSource, a division of VMware




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Oliver Gierke

                                                                                            Spring Data
                                                                                            Core/JPA/MongoDB

                                                                                            ogierke@vmware.com
                                                                                            www.olivergierke.de
                                                                                            olivergierke


2   © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
What to expect?



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Why?




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
How?

                                                    Why?




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
How?

                                                    Why?


                                                                                        What?


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
A Developer‘s View




5
What to expect?
                        NOT!


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
What to expect? NOT!




7
Retrospect
Relational databases
Cloud
Scaling
Data structures
Hibari                                                                 Voldemort
            Membase
                    Riak                                                                  Cassandra
           Redis
SimpleDB                                        (No)SQL                                          MongoDB

                                                    OrientDB                                 CouchDB
        HBase
                                                                                         Sones
                                            Neo4J
 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Graphs
Documents
Column families
Key Value
Forest for the woods?
A Developer‘s View




19
There‘s some
                         Spring for that!


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Spring Data
"                     … provide a familiar and
                         consistent Spring-based
                         programming model while
                         not over-abstracting custom
                         traits of the specific store.



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                               JPA

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                               JPA

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                               JPA

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                               JPA

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                               JPA

© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
JDBC                             JPA




© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Building blocks
Spring
Mapping
Entity mapping

 @Document
 class Person {

     @Id private BigInteger id;
     @Indexed private String firstname, lastname;
     @Field(„email“) private String emailAddress;
     @DBRef private Set<Person> colleagues;

     public Person(String firstname) { … }

     @PersistenceConstructor
     public Person(String firstname, String lastname) { … }

     …
 }




32
Templates
MongoOperations / -Template

 public interface MongoOperations {

     // Generic callback-accepting methods
     <T> T execute(DbCallback<T> action);
     <T> T execute(Class<?> entityClass, CollectionCallback<T> action);
     <T> T execute(String collectionName, CollectionCallback<T> action);

     // Higher level access methods
     <T> List<T> find(Query query, Class<T> entityClass);
     void save(Object objectToSave, String collectionName);
     WriteResult updateFirst(Query query, Update update, Class<?>
         entityClass);

     // Geo API
     <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass);
 }




34
MongoTemplate usage

 // Setup infrastructure
 Mongo mongo = new Mongo();
 MongoDbFactory factory = new SimpleMongoDbFactory(mongo, „foo“);
 MongoTemplate template = new MongoTemplate(factory);

 // Create and save entity
 Person dave = new Person(„Dave“, „Matthews“);
 dave.setEmailAddress(„dave@dmband.com“);
 template.save(person);

 // Query entity
 Query query = new Query(new Criteria(„emailAddress“)
                                     .is(„dave@dmband.com“));
 assertThat(template.find(query), is(dave));




35
Repositories
Repositories

 public interface PersonRepository extends Repository<Person, BigInteger>
 {
   // Finder for a single entity
   Person findByEmailAddress(String emailAddress);

     // Finder for multiple entities
     List<Person> findByLastnameLike(String lastname);

     // Finder with pagination
     Page<Person> findByFirstnameLike(String firstname, Pageable page);

     // Geospatial queries
     List<Person> findByLocationNear(Point location, Distance distance);
     GeoResults<Person> findByLocationNear(Point location);
 }




37
Repositories usage

 <mongo:repositories base-package=„com.acme.repositories“ />


 @Component
 public class MyClient {

     @Autowired
     private PersonRepository repository;

     public List<Person> doSomething() {

         Point point = new Point(43.7, 48.8);
         Distance distance = new Distance(200, Metrics.KILOMETERS);
         return repository.findByLocationNear(point, distance);
     }
 }



38
Repositories
        Querydsl




39
MongoTemplate usage

 public interface QueryDslPredicateExecutor<T> {
   T findOne(Predicate predicate);
   List<T> findAll(Predicate predicate);
 }

 public interface PersonRepository extends Repository<Person, ObjectId>,
   QueryDslPredicateExecutor { … }

 QPerson $ = QPerson.person;
 BooleanExpression left = $.lastname.contains(„eth“);
 BooleanExpression right = $.firstname.is(„Carter“);

 List<Person> result = repository.findAll(left.or(right));
 assertThat(result.size(), is(2));
 assertThat(result, hasItems(dave, carter));




40
JPA
JPA entity mapping

 @Entity
 class Person {

     @Id
     @GeneratedValue(strategy=GenerationType.AUTO)
     private BigInteger id;
     private String firstname, lastname;

     @Column(name=„email“)
     private String emailAddress;

     @OneToMany
     private Set<Person> colleagues;
 }




42
Repository

 public interface PersonRepository extends Repository<Person, BigInteger>
 {
   // Finder for a single entity
   Person findByEmailAddress(String emailAddress);

     // Finder for multiple entities
     List<Person> findByLastnameLike(String lastname);

     // Finder with pagination
     Page<Person> findByFirstnameLike(String firstname, Pageable page);
 }

 <jpa:repositories base-package=„com.acme.repositories“ />




43
Wrap up
Wrap up

•    Sophisticated mapping support
•    Templates
•    Repositories
•    Querydsl
•    Spring namespace
•    Geospatial support
•    Cross-store persistence




45
Upcoming Talks

• Today
     – 10:15 - Spring Data Gemfire
     – 12:45 - Spring Data MongoDB & CloudFoundry
     – 4:30 - Spring Data Neo4J


• Thursday
     – 8:30 - Spring Data JPA & Repositories
     – 10:15 - Polyglot persistence


• Friday
     – 8:30 - SQLFire



46
Play with it



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Participate



© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Spread the word


© 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
Questions?
Resources

• www.springframework.org/spring-data
• github.com/SpringSource/spring-data-mongodb
• http://www.se-radio.net/2010/07/episode-165-nosql-
  and-mongodb-with-dwight-merriman
• http://kkovacs.eu/cassandra-vs-mongodb-vs-
  couchdb-vs-redis




51
Sources
•    Building blocks - http://www.sxc.hu/photo/297189
•    Columns - http://www.sxc.hu/photo/1033540
•    Dilemma - http://www.sxc.hu/photo/125069
•    Forest - http://www.sxc.hu/photo/1274066
•    Glasses - http://www.sxc.hu/photo/696003
•    Mapping - http://www.sxc.hu/photo/1253374
•    Nails - http://www.sxc.hu/photo/933587
•    Questions - http://www.sxc.hu/photo/860327
•    Repository - http://www.sxc.hu/photo/1042408
•    Retrospect - http://www.sxc.hu/photo/921297
•    Spreadsheet - http://www.sxc.hu/photo/338505
•    Spring - http://www.sxc.hu/photo/1291358
•    Umbrella - http://www.sxc.hu/photo/1364634
•    Template - http://www.sxc.hu/photo/619819
•    Wrap up - http://www.sxc.hu/photo/922227




52

More Related Content

What's hot

The Coming Database Revolution
The Coming Database RevolutionThe Coming Database Revolution
The Coming Database Revolution
DATAVERSITY
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
Mumbai Academisc
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernatehr1383
 
Elasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational databaseElasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational database
Kristijan Duvnjak
 
Is multi-model the future of NoSQL?
Is multi-model the future of NoSQL?Is multi-model the future of NoSQL?
Is multi-model the future of NoSQL?
Max Neunhöffer
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
S.Shayan Daneshvar
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearch
sirensolutions
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
David McCarter
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
gillygize
 
OData and SharePoint
OData and SharePointOData and SharePoint
OData and SharePointSanjay Patel
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHP
Dave Stokes
 
Data Abstraction for Large Web Applications
Data Abstraction for Large Web ApplicationsData Abstraction for Large Web Applications
Data Abstraction for Large Web Applicationsbrandonsavage
 
API
APIAPI
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming Languages
S.Shayan Daneshvar
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
David McCarter
 
ArangoDB
ArangoDBArangoDB
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
Clifford James
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1b_kathir
 
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
ukdpe
 
ElasticSearch, Elastica, ElasticaBundle
ElasticSearch, Elastica, ElasticaBundleElasticSearch, Elastica, ElasticaBundle
ElasticSearch, Elastica, ElasticaBundle
Nicolas Badey
 

What's hot (20)

The Coming Database Revolution
The Coming Database RevolutionThe Coming Database Revolution
The Coming Database Revolution
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Introduction to hibernate
Introduction to hibernateIntroduction to hibernate
Introduction to hibernate
 
Elasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational databaseElasticsearch as a search alternative to a relational database
Elasticsearch as a search alternative to a relational database
 
Is multi-model the future of NoSQL?
Is multi-model the future of NoSQL?Is multi-model the future of NoSQL?
Is multi-model the future of NoSQL?
 
Introduction to MongoDB
Introduction to MongoDBIntroduction to MongoDB
Introduction to MongoDB
 
Searching Relational Data with Elasticsearch
Searching Relational Data with ElasticsearchSearching Relational Data with Elasticsearch
Searching Relational Data with Elasticsearch
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
Connecting to a REST API in iOS
Connecting to a REST API in iOSConnecting to a REST API in iOS
Connecting to a REST API in iOS
 
OData and SharePoint
OData and SharePointOData and SharePoint
OData and SharePoint
 
MySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHPMySQL without the SQL -- Cascadia PHP
MySQL without the SQL -- Cascadia PHP
 
Data Abstraction for Large Web Applications
Data Abstraction for Large Web ApplicationsData Abstraction for Large Web Applications
Data Abstraction for Large Web Applications
 
API
APIAPI
API
 
Advanced SQL - Database Access from Programming Languages
Advanced SQL - Database Access  from Programming LanguagesAdvanced SQL - Database Access  from Programming Languages
Advanced SQL - Database Access from Programming Languages
 
Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)Building nTier Applications with Entity Framework Services (Part 2)
Building nTier Applications with Entity Framework Services (Part 2)
 
ArangoDB
ArangoDBArangoDB
ArangoDB
 
Intro to Elasticsearch
Intro to ElasticsearchIntro to Elasticsearch
Intro to Elasticsearch
 
Hibernate Session 1
Hibernate Session 1Hibernate Session 1
Hibernate Session 1
 
LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1LINQ to Relational in Visual Studio 2008 SP1
LINQ to Relational in Visual Studio 2008 SP1
 
ElasticSearch, Elastica, ElasticaBundle
ElasticSearch, Elastica, ElasticaBundleElasticSearch, Elastica, ElasticaBundle
ElasticSearch, Elastica, ElasticaBundle
 

Viewers also liked

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
Staples
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
Oliver Gierke
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and Hadoop
Steven Francia
 
Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)
lyonjug
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Oliver Gierke
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
Oliver Gierke
 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
Joshua Long
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring DataAnton Sulzhenko
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
Gunnar Hillert
 
Spring Batch Workshop
Spring Batch WorkshopSpring Batch Workshop
Spring Batch Workshop
lyonjug
 
REST with Spring Boot #jqfk
REST with Spring Boot #jqfkREST with Spring Boot #jqfk
REST with Spring Boot #jqfk
Toshiaki Maki
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
Eberhard Wolff
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
Joshua Long
 
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
Data Microservices with Spring Cloud Stream, Task,  and Data Flow #jsug #spri...Data Microservices with Spring Cloud Stream, Task,  and Data Flow #jsug #spri...
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
Toshiaki Maki
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring Cloud
Eberhard Wolff
 
Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)
Reshmi Krishna
 

Viewers also liked (16)

Easy data-with-spring-data-jpa
Easy data-with-spring-data-jpaEasy data-with-spring-data-jpa
Easy data-with-spring-data-jpa
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Introduction to MongoDB and Hadoop
Introduction to MongoDB and HadoopIntroduction to MongoDB and Hadoop
Introduction to MongoDB and Hadoop
 
Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)Spring Batch Workshop (advanced)
Spring Batch Workshop (advanced)
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
 
MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 
Spring Batch Performance Tuning
Spring Batch Performance TuningSpring Batch Performance Tuning
Spring Batch Performance Tuning
 
Spring Batch Workshop
Spring Batch WorkshopSpring Batch Workshop
Spring Batch Workshop
 
REST with Spring Boot #jqfk
REST with Spring Boot #jqfkREST with Spring Boot #jqfk
REST with Spring Boot #jqfk
 
Microservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring CloudMicroservices with Java, Spring Boot and Spring Cloud
Microservices with Java, Spring Boot and Spring Cloud
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
Data Microservices with Spring Cloud Stream, Task,  and Data Flow #jsug #spri...Data Microservices with Spring Cloud Stream, Task,  and Data Flow #jsug #spri...
Data Microservices with Spring Cloud Stream, Task, and Data Flow #jsug #spri...
 
Microservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring CloudMicroservice With Spring Boot and Spring Cloud
Microservice With Spring Boot and Spring Cloud
 
Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)Implementing microservices tracing with spring cloud and zipkin (spring one)
Implementing microservices tracing with spring cloud and zipkin (spring one)
 

Similar to An Introduction to Spring Data

Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Oliver Gierke
 
Hadoop for carrier
Hadoop for carrierHadoop for carrier
Hadoop for carrier
Flytxt
 
Comparing JVM Web Frameworks - TSSJS 2011
Comparing JVM Web Frameworks - TSSJS 2011Comparing JVM Web Frameworks - TSSJS 2011
Comparing JVM Web Frameworks - TSSJS 2011
Matt Raible
 
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBCUsing SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
Kingsley Uyi Idehen
 
What's New in Spring 3.1
What's New in Spring 3.1What's New in Spring 3.1
What's New in Spring 3.1
Matt Raible
 
Flowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDBFlowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDB
Flowdock
 
Oracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with LessOracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with Less
Ed Burns
 
JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011Edward Burns
 
LatJUG. Spring Roo
LatJUG. Spring RooLatJUG. Spring Roo
LatJUG. Spring Roo
denis Udod
 
Comparing JVM Web Frameworks - 33rd Degree
Comparing JVM Web Frameworks - 33rd DegreeComparing JVM Web Frameworks - 33rd Degree
Comparing JVM Web Frameworks - 33rd Degree
Matt Raible
 
WebBee rapid web app development teck stack
WebBee rapid web app development teck stackWebBee rapid web app development teck stack
WebBee rapid web app development teck stack
ALDAN3
 
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-endUsing Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Kingsley Uyi Idehen
 
Exploiting Linked Data via Filemaker
Exploiting Linked Data via FilemakerExploiting Linked Data via Filemaker
Exploiting Linked Data via Filemaker
Kingsley Uyi Idehen
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Edward Burns
 
2000: Making IT Happen with J2EE
2000: Making IT Happen with J2EE2000: Making IT Happen with J2EE
2000: Making IT Happen with J2EE
Russell Castagnaro
 
Exploiting Linked (Open) Data via Microsoft Access
Exploiting Linked (Open) Data via Microsoft AccessExploiting Linked (Open) Data via Microsoft Access
Exploiting Linked (Open) Data via Microsoft Access
Kingsley Uyi Idehen
 
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNsExploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
Kingsley Uyi Idehen
 
Java, Up to Date
Java, Up to DateJava, Up to Date
Java, Up to Date
輝 子安
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run Everywhere
Mike North
 
Sharepoint and SQL Server 2012
Sharepoint and SQL Server 2012Sharepoint and SQL Server 2012
Sharepoint and SQL Server 2012
James Tramel
 

Similar to An Introduction to Spring Data (20)

Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 
Hadoop for carrier
Hadoop for carrierHadoop for carrier
Hadoop for carrier
 
Comparing JVM Web Frameworks - TSSJS 2011
Comparing JVM Web Frameworks - TSSJS 2011Comparing JVM Web Frameworks - TSSJS 2011
Comparing JVM Web Frameworks - TSSJS 2011
 
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBCUsing SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
Using SAP Crystal Reports as a Linked (Open) Data Front-End via ODBC
 
What's New in Spring 3.1
What's New in Spring 3.1What's New in Spring 3.1
What's New in Spring 3.1
 
Flowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDBFlowdock's full-text search with MongoDB
Flowdock's full-text search with MongoDB
 
Oracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with LessOracle WebLogic Server 12.2.1 Do More with Less
Oracle WebLogic Server 12.2.1 Do More with Less
 
JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011JSF 2.2 Status at DOAG 2011
JSF 2.2 Status at DOAG 2011
 
LatJUG. Spring Roo
LatJUG. Spring RooLatJUG. Spring Roo
LatJUG. Spring Roo
 
Comparing JVM Web Frameworks - 33rd Degree
Comparing JVM Web Frameworks - 33rd DegreeComparing JVM Web Frameworks - 33rd Degree
Comparing JVM Web Frameworks - 33rd Degree
 
WebBee rapid web app development teck stack
WebBee rapid web app development teck stackWebBee rapid web app development teck stack
WebBee rapid web app development teck stack
 
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-endUsing Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
Using Tibco SpotFire (via Virtuoso ODBC) as Linked Data Front-end
 
Exploiting Linked Data via Filemaker
Exploiting Linked Data via FilemakerExploiting Linked Data via Filemaker
Exploiting Linked Data via Filemaker
 
Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015Java EE 7 from an HTML5 Perspective, JavaLand 2015
Java EE 7 from an HTML5 Perspective, JavaLand 2015
 
2000: Making IT Happen with J2EE
2000: Making IT Happen with J2EE2000: Making IT Happen with J2EE
2000: Making IT Happen with J2EE
 
Exploiting Linked (Open) Data via Microsoft Access
Exploiting Linked (Open) Data via Microsoft AccessExploiting Linked (Open) Data via Microsoft Access
Exploiting Linked (Open) Data via Microsoft Access
 
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNsExploiting Linked (Open) Data via Microsoft Access using ODBC  File DSNs
Exploiting Linked (Open) Data via Microsoft Access using ODBC File DSNs
 
Java, Up to Date
Java, Up to DateJava, Up to Date
Java, Up to Date
 
Write Once, Run Everywhere
Write Once, Run EverywhereWrite Once, Run Everywhere
Write Once, Run Everywhere
 
Sharepoint and SQL Server 2012
Sharepoint and SQL Server 2012Sharepoint and SQL Server 2012
Sharepoint and SQL Server 2012
 

More from Oliver Gierke

An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
Oliver Gierke
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?Oliver Gierke
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Oliver Gierke
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
Oliver Gierke
 
Spring integration
Spring integrationSpring integration
Spring integration
Oliver Gierke
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDBOliver Gierke
 
Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)
Oliver Gierke
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivity
Oliver Gierke
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring Roo
Oliver Gierke
 
Sophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesSophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & Hades
Oliver Gierke
 
Coding & Music Passion And Profession
Coding & Music   Passion And ProfessionCoding & Music   Passion And Profession
Coding & Music Passion And Profession
Oliver Gierke
 
REST based web applications with Spring 3
REST based web applications with Spring 3REST based web applications with Spring 3
REST based web applications with Spring 3
Oliver Gierke
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With Hades
Oliver Gierke
 

More from Oliver Gierke (14)

An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
 
Whoops! where did my architecture go?
Whoops! where did my architecture go?Whoops! where did my architecture go?
Whoops! where did my architecture go?
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivity
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring Roo
 
Sophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesSophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & Hades
 
Coding & Music Passion And Profession
Coding & Music   Passion And ProfessionCoding & Music   Passion And Profession
Coding & Music Passion And Profession
 
REST based web applications with Spring 3
REST based web applications with Spring 3REST based web applications with Spring 3
REST based web applications with Spring 3
 
Mylyn
MylynMylyn
Mylyn
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With Hades
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 

An Introduction to Spring Data

  • 1. An Introduction to Spring Data Oliver Gierke - SpringSource, a division of VMware © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 2. Oliver Gierke Spring Data Core/JPA/MongoDB ogierke@vmware.com www.olivergierke.de olivergierke 2 © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 3. What to expect? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 4. Why? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 5. How? Why? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 6. How? Why? What? © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 8. What to expect? NOT! © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 12. Cloud
  • 15. Hibari Voldemort Membase Riak Cassandra Redis SimpleDB (No)SQL MongoDB OrientDB CouchDB HBase Sones Neo4J © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 20. Forest for the woods?
  • 22. There‘s some Spring for that! © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 24. " … provide a familiar and consistent Spring-based programming model while not over-abstracting custom traits of the specific store. © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 25. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 26. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 27. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 28. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 29. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 30. JDBC JPA © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 34. Entity mapping @Document class Person { @Id private BigInteger id; @Indexed private String firstname, lastname; @Field(„email“) private String emailAddress; @DBRef private Set<Person> colleagues; public Person(String firstname) { … } @PersistenceConstructor public Person(String firstname, String lastname) { … } … } 32
  • 36. MongoOperations / -Template public interface MongoOperations { // Generic callback-accepting methods <T> T execute(DbCallback<T> action); <T> T execute(Class<?> entityClass, CollectionCallback<T> action); <T> T execute(String collectionName, CollectionCallback<T> action); // Higher level access methods <T> List<T> find(Query query, Class<T> entityClass); void save(Object objectToSave, String collectionName); WriteResult updateFirst(Query query, Update update, Class<?> entityClass); // Geo API <T> GeoResults<T> geoNear(NearQuery near, Class<T> entityClass); } 34
  • 37. MongoTemplate usage // Setup infrastructure Mongo mongo = new Mongo(); MongoDbFactory factory = new SimpleMongoDbFactory(mongo, „foo“); MongoTemplate template = new MongoTemplate(factory); // Create and save entity Person dave = new Person(„Dave“, „Matthews“); dave.setEmailAddress(„dave@dmband.com“); template.save(person); // Query entity Query query = new Query(new Criteria(„emailAddress“) .is(„dave@dmband.com“)); assertThat(template.find(query), is(dave)); 35
  • 39. Repositories public interface PersonRepository extends Repository<Person, BigInteger> { // Finder for a single entity Person findByEmailAddress(String emailAddress); // Finder for multiple entities List<Person> findByLastnameLike(String lastname); // Finder with pagination Page<Person> findByFirstnameLike(String firstname, Pageable page); // Geospatial queries List<Person> findByLocationNear(Point location, Distance distance); GeoResults<Person> findByLocationNear(Point location); } 37
  • 40. Repositories usage <mongo:repositories base-package=„com.acme.repositories“ /> @Component public class MyClient { @Autowired private PersonRepository repository; public List<Person> doSomething() { Point point = new Point(43.7, 48.8); Distance distance = new Distance(200, Metrics.KILOMETERS); return repository.findByLocationNear(point, distance); } } 38
  • 41. Repositories Querydsl 39
  • 42. MongoTemplate usage public interface QueryDslPredicateExecutor<T> { T findOne(Predicate predicate); List<T> findAll(Predicate predicate); } public interface PersonRepository extends Repository<Person, ObjectId>, QueryDslPredicateExecutor { … } QPerson $ = QPerson.person; BooleanExpression left = $.lastname.contains(„eth“); BooleanExpression right = $.firstname.is(„Carter“); List<Person> result = repository.findAll(left.or(right)); assertThat(result.size(), is(2)); assertThat(result, hasItems(dave, carter)); 40
  • 43. JPA
  • 44. JPA entity mapping @Entity class Person { @Id @GeneratedValue(strategy=GenerationType.AUTO) private BigInteger id; private String firstname, lastname; @Column(name=„email“) private String emailAddress; @OneToMany private Set<Person> colleagues; } 42
  • 45. Repository public interface PersonRepository extends Repository<Person, BigInteger> { // Finder for a single entity Person findByEmailAddress(String emailAddress); // Finder for multiple entities List<Person> findByLastnameLike(String lastname); // Finder with pagination Page<Person> findByFirstnameLike(String firstname, Pageable page); } <jpa:repositories base-package=„com.acme.repositories“ /> 43
  • 47. Wrap up • Sophisticated mapping support • Templates • Repositories • Querydsl • Spring namespace • Geospatial support • Cross-store persistence 45
  • 48. Upcoming Talks • Today – 10:15 - Spring Data Gemfire – 12:45 - Spring Data MongoDB & CloudFoundry – 4:30 - Spring Data Neo4J • Thursday – 8:30 - Spring Data JPA & Repositories – 10:15 - Polyglot persistence • Friday – 8:30 - SQLFire 46
  • 49. Play with it © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 50. Participate © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 51. Spread the word © 2011 SpringOne 2GX 2011. All rights reserved. Do not distribute without permission.
  • 53. Resources • www.springframework.org/spring-data • github.com/SpringSource/spring-data-mongodb • http://www.se-radio.net/2010/07/episode-165-nosql- and-mongodb-with-dwight-merriman • http://kkovacs.eu/cassandra-vs-mongodb-vs- couchdb-vs-redis 51
  • 54. Sources • Building blocks - http://www.sxc.hu/photo/297189 • Columns - http://www.sxc.hu/photo/1033540 • Dilemma - http://www.sxc.hu/photo/125069 • Forest - http://www.sxc.hu/photo/1274066 • Glasses - http://www.sxc.hu/photo/696003 • Mapping - http://www.sxc.hu/photo/1253374 • Nails - http://www.sxc.hu/photo/933587 • Questions - http://www.sxc.hu/photo/860327 • Repository - http://www.sxc.hu/photo/1042408 • Retrospect - http://www.sxc.hu/photo/921297 • Spreadsheet - http://www.sxc.hu/photo/338505 • Spring - http://www.sxc.hu/photo/1291358 • Umbrella - http://www.sxc.hu/photo/1364634 • Template - http://www.sxc.hu/photo/619819 • Wrap up - http://www.sxc.hu/photo/922227 52