Spring Data MongoDB - Spring Web Services - Parent - SpringSource

Spring Data MongoDB - Spring Web Services - Parent - SpringSource Spring Data MongoDB - Spring Web Services - Parent - SpringSource

static.springsource.org
from static.springsource.org More from this publisher
13.07.2015 Views

please define productname in your docbook file!class GridFsClient {@AutowiredGridFsOperations operations;}@Testpublic void readFilesFromGridFs {GridFsResources[] txtFiles = operations.getResources("*.txt");}Example 5.31 Using GridFsTemplate to read filesGridFsOperations extending ResourcePatternResolver allows the GridFsTemplate e.g. tobe plugged into an ApplicationContext to read Spring Config files from a MongoDB.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 69

please define productname in your docbook file!6. MongoDB repositories6.1 IntroductionThis chapter will point out the specialties for repository support for MongoDB. This builds on the corerepository support explained in Chapter 4, Working with Spring Data Repositories. So make sure you'vegot a sound understanding of the basic concepts explained there.6.2 UsageTo access domain entities stored in a MongoDB you can leverage our sophisticated repository supportthat eases implementing those quite significantly. To do so, simply create an interface for your repository:public class Person {@Idprivate String id;private String firstname;private String lastname;private Address address;}// … getters and setters omittedExample 6.1 Sample Person entityWe have a quite simple domain object here. Note that it has a property named id of typeObjectId.The default serialization mechanism used in MongoTemplate (which is backing the repositorysupport) regards properties named id as document id. Currently we supportString, ObjectId andBigInteger as id-types.public interface PersonRepository extends PagingAndSortingRepository {}// additional custom finder methods go hereExample 6.2 Basic repository interface to persist Person entitiesRight now this interface simply serves typing purposes but we will add additional methods to it later. Inyour Spring configuration simply add1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 70

please define productname in your docbook file!class GridFsClient {@AutowiredGridFsOperations operations;}@Testpublic void readFilesFromGridFs {GridFsResources[] txtFiles = operations.getResources("*.txt");}Example 5.31 Using GridFsTemplate to read filesGridFsOperations extending ResourcePatternResolver allows the GridFsTemplate e.g. tobe plugged into an ApplicationContext to read <strong>Spring</strong> Config files from a <strong>MongoDB</strong>.1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!