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.
Basically, the application stores customer locations. The domain is modeled as follows:
The required setup and data set are already provided.
Please complete classes JpaTest
and CustomersRepository
. This test suite relies on an embedded H2 database.
- Find a customer by its ID (lookup user with id 42)
- Find all customers
- Get paginated customer results (2nd page [page indices are 0-based], 5 people per page)
- Find customers with name compound predicate using explicit queries
- Find by name and city, using QueryDSL (CustomersRepository must extend
QueryDslPredicateExecutor
)
Spring Data/Mongo DB reference
The toy application here models blog posts, written by authors and commented, as illustrated here:
Again, the data set and the setup are taken care of for you.
Similarly, please fix the failing tests of MongoTest
.
- Find blog posts by their contents ("Miami")
- Find authors within a radius of 70 (center: [0,0]) whose last name starts with "Biv"
- Find all pictures of a post, via custom repository implementation
PostRepositoryImpl
. Your implementation will rely onGridFsTemplate
to execute an instance oforg.springframework.data.mongodb.core.query.Query
. You can construct one out of criteria objects (e.g.:org.springframework.data.mongodb.gridfs.GridFsCriteria.whereFilename
belonging inpost.getPictures()
).
(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:
Open Neo4JTest
and go green!
- Find a user (@ebottard i.e. "ebottard") by name
- Craft a query that will allow you to find tweets by sender name, and use it to retrieve @ebottard's tweets
- Retrieve Chris Richardson (@crichardson i.e. "crichardson") account suggestions, using an explicit Cypher query
(see Javadoc in
Neo4JTest
for complete specs about that) - Make Andy Piper (@andypiper i.e. "andypiper") follow his account suggestions, based on your previous query
- Find all tweets tagged with #devoxx, using Cypher Java DSL
- Run
mvn tomcat:run
- Open/curl/use Spring Shell to 'localhost:8080/hands-on-springdata'
- Explore :)