Skip to content

ericbottard/hands-on-spring-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HANDS ON SPRING DATA

Ready to rumble?

Foreword

All exercises consist in making their corresponding test suite pass. This will require some adaptation within the tests themselves as well as other related classes (Repository...).

This Hands On has been tested with Eclipse, but any other IDE should work. We recommend using the SpringSource ToolSuite distro, which has Maven support and SpringData awareness built-in. You should import the project as an "Existing Maven project".

The main gotcha is having QueryDSL work in your IDE. Configuration files for eclipse are included, for other IDEs, your mileage may vary.

Exercise 1: JPA

Spring Data/JPA reference

Basically, the application stores customer locations. The domain is modeled as follows:

Customers Data Model

TODO

The required setup and data set are already provided. Please complete classes JpaTest and CustomersRepository. This test suite relies on an embedded H2 database.

  1. Find a customer by its ID (lookup user with id 42)
  2. Find all customers
  3. Get paginated customer results (2nd page [page indices are 0-based], 5 people per page)
  4. Find customers with name compound predicate using explicit queries
  5. Find by name and city, using QueryDSL (CustomersRepository must extend QueryDslPredicateExecutor)

Exercise 2: Mongo DB

Spring Data/Mongo DB reference

The toy application here models blog posts, written by authors and commented, as illustrated here:

Blog Data Model

TODO

Again, the data set and the setup are taken care of for you. Similarly, please fix the failing tests of MongoTest.

  1. Find blog posts by their contents ("Miami")
  2. Find authors within a radius of 70 (center: [0,0]) whose last name starts with "Biv"
  3. Find all pictures of a post, via custom repository implementation PostRepositoryImpl. Your implementation will rely on GridFsTemplate to execute an instance of org.springframework.data.mongodb.core.query.Query. You can construct one out of criteria objects (e.g.: org.springframework.data.mongodb.gridfs.GridFsCriteria.whereFilename belonging in post.getPictures()).

Exercise 3: Neo4J

Spring Data/Neo4J reference

(Derived from Michael Hunger's work.)

Everyone knows about Twitter. Rumor has it Twitter has moved to Neo4J! We used Michael's application to query for some tweets about #cloudfoundry (http://www.cloudfoundry.com) and saved the results. The dataset is provided for you. The model is defined as follows:

Tweets Data Model

TODO

Open Neo4JTestand go green!

  1. Find a user (@ebottard i.e. "ebottard") by name
  2. Craft a query that will allow you to find tweets by sender name, and use it to retrieve @ebottard's tweets
  3. Retrieve Chris Richardson (@crichardson i.e. "crichardson") account suggestions, using an explicit Cypher query (see Javadoc in Neo4JTest for complete specs about that)
  4. Make Andy Piper (@andypiper i.e. "andypiper") follow his account suggestions, based on your previous query
  5. Find all tweets tagged with #devoxx, using Cypher Java DSL

Bonus: Spring Data REST

  1. Run mvn tomcat:run
  2. Open/curl/use Spring Shell to 'localhost:8080/hands-on-springdata'
  3. Explore :)

About

Exercises for learning Spring Data JPA, Mongo, Neo4j and friends

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages