From 3cb857ef0561f7c5808ca75f166d65fbe82f412a Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Fri, 3 Dec 2010 11:57:07 -0500 Subject: [PATCH] README updates. --- README.md | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index b5e926f82..acd07de4e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Getting Help At this point your best bet is to look at the Look at the [JavaDocs](http://static.springsource.org/spring-data/data-document/docs/1.0.0.BUILD-SNAPSHOT/spring-data-mongodb/apidocs/) for MongoDB integration and corresponding and source code. For more detailed questions, use the [forum](http://forum.springsource.org/forumdisplay.php?f=80). If you are new to Spring as well as to Spring Data, look for information about [Spring projects](http://www.springsource.org/projects). -The [User Guide](http://static.springsource.org/spring-data/datastore-keyvalue/snapshot-site/reference/html/) (A work in progress). +The [User Guide](http://static.springsource.org/spring-data/data-document/docs/1.0.0.BUILD-SNAPSHOT/reference/html/) (A work in progress). @@ -37,45 +37,54 @@ For those in a hurry: http://maven.springframework.org/snapshot +### MongoTemplate +MongoTemplate is the central support class for Mongo database operations. It provides -* The MongoTemplate is the central support class for Mongo database operations. It supports - * Basic POJO mapping support to and from BSON - * Connection Affinity callback - * Exception translation into Spring's +* Basic POJO mapping support to and from BSON +* Connection Affinity callback +* Exception translation into Spring's [technology agnostic DAO exception hierarchy](http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/dao.html#dao-exceptions). Future plans are to support optional logging and/or exception throwing based on WriteResult return value, common map-reduce operations, GridFS operations. A simple API for partial document updates is also planned. -* To simplify the creation of Data Repositories a generic Repository interface and base class is provided. Furthermore, Spring will automatically create a Repository implementation for you that add implementations of finder methods you specify on an interface. For example the Repository interface is +### Easy Data Repository generation - -`public interface Repository {` +To simplify the creation of Data Repositories a generic Repository interface and default implementation is provided. Furthermore, Spring will automatically create a Repository implementation for you that adds implementations of finder methods you specify on an interface. - T save(T entity); +The Repository interface is - List save(Iterable entities); + public interface Repository { - T findById(ID id); + T save(T entity); - boolean exists(ID id); + List save(Iterable entities); - List findAll(); + T findById(ID id); - Long count(); + boolean exists(ID id); - void delete(T entity); + List findAll(); - void delete(Iterable entities); + Long count(); - void deleteAll(); -`}` + void delete(T entity); -and there is a placeholder interface called MongoRepository that will in future add more Mongo specific methods. + void delete(Iterable entities); + + void deleteAll(); + } + + +The MongoRepository extends Repository and will in future add more Mongo specific methods. 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 +SimpleMongoRepository is the out of the box implementation of the MongoRepository you can use for basid CRUD operations. + +To go beyond basic CRUD, extend the MongoRepository interface and supply your own finder methods that follow simple naming conventions such that they can be easily converted into queries. + +For example, given a Person class with first and last name properties, a PersonRepository interface that can query for Person by last name and when the first name matches a regular expression is shown below public interface PersonRepository extends MongoRepository {