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!5. MongoDB supportThe MongoDB support contains a wide range of features which are summarized below.• Spring configuration support using Java based @Configuration classes or an XML namespace for aMongo driver instance and replica sets• MongoTemplate helper class that increases productivity performing common Mongo operations.Includes integrated object mapping between documents and POJOs.• Exception translation into Spring's portable Data Access Exception hierarchy• Feature Rich Object Mapping integrated with Spring's Conversion Service• Annotation based mapping metadata but extensible to support other metadata formats• Persistence and mapping lifecycle events• Java based Query, Criteria, and Update DSLs• Automatic implementatin of Repository interfaces including support for custom finder methods.• QueryDSL integration to support type-safe queries.• Cross-store persistance - support for JPA Entities with fields transparently persisted/retrieved usingMongoDB• Log4j log appender• GeoSpatial integrationFor most tasks you will find yourself using MongoTemplate or the Repository support that both leveragethe rich mapping functionality. MongoTemplate is the place to look for accessing functionality such asincrementing counters or ad-hoc CRUD operations. MongoTemplate also provides callback methods sothat it is easy for you to get a hold of the low level API artifacts such as org.mongo.DB to communicatedirectly with MongoDB. The goal with naming conventions on various API artifacts is to copy those inthe base MongoDB Java driver so you can easily map your existing knowledge onto the Spring APIs.5.1 Getting StartedSpring MongoDB support requires MongoDB 1.4 or higher and Java SE 5 or higher. The latestproduction release (2.0.x as of this writing) is recommended. An easy way to bootstrap setting up aworking environment is to create a Spring based project in STS.First you need to set up a running Mongodb server. Refer to the Mongodb Quick Start guide for anexplanation on how to startup a MongoDB instance. Once installed starting MongoDB is typically amatter of executing the following command: MONGO_HOME/bin/mongodTo create a Spring project in STS go to File -> New -> Spring Template Project -> Simple SpringUtility Project --> press Yes when prompted. Then enter a project and a package name such asorg.spring.mongodb.example.Then add the following to pom.xml dependencies section.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 25

please define productname in your docbook file!org.springframework.dataspring-data-mongodb1.1.0.RELEASEAlso change the version of Spring in the pom.xml to be3.1.2.RELEASEYou will also need to add the location of the Spring Milestone repository for maven to your pom.xmlwhich is at the same level of your elementspring-milestoneSpring Maven MILESTONE Repositoryhttp://repo.springsource.org/libs-milestoneThe repository is also browseable here.You may also want to set the logging level to DEBUG to see some additional information, edit thelog4j.properties file to havelog4j.category.org.springframework.data.document.mongodb=DEBUGlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%nCreate a simple Person class to persist1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 26

please define productname in your docbook file!org.springframework.dataspring-data-mongodb1.1.0.RELEASEAlso change the version of <strong>Spring</strong> in the pom.xml to be3.1.2.RELEASEYou will also need to add the location of the <strong>Spring</strong> Milestone repository for maven to your pom.xmlwhich is at the same level of your elementspring-milestone<strong>Spring</strong> Maven MILESTONE Repositoryhttp://repo.springsource.org/libs-milestoneThe repository is also browseable here.You may also want to set the logging level to DEBUG to see some additional information, edit thelog4j.properties file to havelog4j.category.org.springframework.data.document.mongodb=DEBUGlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%nCreate a simple Person class to persist1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 26

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

Saved successfully!

Ooh no, something went wrong!