Coder Social home page Coder Social logo

hands-on-spring-data's Introduction

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 :)

hands-on-spring-data's People

Contributors

ericbottard avatar

Watchers

James Cloos avatar timolee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.