From d592028890f467f658b4cc52c8c95af49c065d01 Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Fri, 3 Dec 2010 10:58:41 -0500 Subject: [PATCH] README updates. --- README.md | 69 ++++++++++++++++++++++++++----------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 262c86e4f..5fe5d486b 100644 --- a/README.md +++ b/README.md @@ -68,64 +68,61 @@ Future plans are to support optional logging and/or exception throwing based on and there is a placeholder interface called MongoRepository that will in future add more Mongo specific methods. -public interface MongoRepository extends + public interface MongoRepository extends Repository { - -} + } You can use the provided implementation class SimpleMongoRepository for basic data access. You can also extend the MongoRepository interface and supply your own finder methods that follow simple naming conventions so they can be converted into queries. For example, given a Person class with first and last name properties -public interface PersonRepository extends MongoRepository { + public interface PersonRepository extends MongoRepository { - List findByLastname(String lastname); + List findByLastname(String lastname); - - List findByFirstnameLike(String firstname); -} + List findByFirstnameLike(String firstname); + } You can have Spring automatically generate the implemention as shown below - - - - - - - - - - + + + + + + + + + + - - - - + + + + This will register an object in the container named PersonRepository. You can use it as shown below -@Service -public class MyService { + @Service + public class MyService { - @Autowired - PersonRepository repository; + @Autowired + PersonRepository repository; - @Test - public void doWork() { + public void doWork() { - repository.deleteAll(); + repository.deleteAll(); - Person person = new Person(); - person.setFirstname("Oliver"); - person.setLastname("Gierke"); - person = repository.save(person); + Person person = new Person(); + person.setFirstname("Oliver"); + person.setLastname("Gierke"); + person = repository.save(person); - List lastNameResults = repository.findByLastname("Gierke"); + List lastNameResults = repository.findByLastname("Gierke"); - List firstNameResults = repository.findByFirstnameLike("Oli*"); + List firstNameResults = repository.findByFirstnameLike("Oli*"); + } } -} ## CouchDB