README updates.
This commit is contained in:
67
README.md
67
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).
|
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:
|
|||||||
<url>http://maven.springframework.org/snapshot</url>
|
<url>http://maven.springframework.org/snapshot</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
### 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
|
||||||
* Basic POJO mapping support to and from BSON
|
* Connection Affinity callback
|
||||||
* 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).
|
||||||
* Exception translation into Spring's
|
|
||||||
|
|
||||||
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.
|
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
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
The Repository interface is
|
||||||
|
|
||||||
|
public interface Repository<T, ID extends Serializable> {
|
||||||
|
|
||||||
|
T save(T entity);
|
||||||
|
|
||||||
|
List<T> save(Iterable<? extends T> entities);
|
||||||
|
|
||||||
|
T findById(ID id);
|
||||||
|
|
||||||
|
boolean exists(ID id);
|
||||||
|
|
||||||
|
List<T> findAll();
|
||||||
|
|
||||||
|
Long count();
|
||||||
|
|
||||||
|
void delete(T entity);
|
||||||
|
|
||||||
|
void delete(Iterable<? extends T> entities);
|
||||||
|
|
||||||
|
void deleteAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
`public interface Repository<T, ID extends Serializable> {`
|
The MongoRepository extends Repository and will in future add more Mongo specific methods.
|
||||||
|
|
||||||
T save(T entity);
|
|
||||||
|
|
||||||
List<T> save(Iterable<? extends T> entities);
|
|
||||||
|
|
||||||
T findById(ID id);
|
|
||||||
|
|
||||||
boolean exists(ID id);
|
|
||||||
|
|
||||||
List<T> findAll();
|
|
||||||
|
|
||||||
Long count();
|
|
||||||
|
|
||||||
void delete(T entity);
|
|
||||||
|
|
||||||
void delete(Iterable<? extends T> entities);
|
|
||||||
|
|
||||||
void deleteAll();
|
|
||||||
`}`
|
|
||||||
|
|
||||||
and there is a placeholder interface called MongoRepository that will in future add more Mongo specific methods.
|
|
||||||
|
|
||||||
public interface MongoRepository<T, ID extends Serializable> extends
|
public interface MongoRepository<T, ID extends Serializable> extends
|
||||||
Repository<T, ID> {
|
Repository<T, ID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
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<Person, Long> {
|
public interface PersonRepository extends MongoRepository<Person, Long> {
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user