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!public class PersonWriteConverter implements Converter {public DBObject convert(Person source) {DBObject dbo = new BasicDBObject();dbo.put("_id", source.getId());dbo.put("name", source.getFirstName());dbo.put("age", source.getAge());return dbo;}}1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 87

please define productname in your docbook file!8. Cross Store supportSometimes you need to store data in multiple data stores and these data stores can be of differenttypes. One might be relational while the other a document store. For this use case we have created aseparate module in the MongoDB support that handles what we call cross-store support. The currentimplemenatation is based on JPA as the driver for the relational database and we allow select fields inthe Entities to be stored in a Mongo database. In addition to allowing you to store your data in two storeswe also coordinate persistence operations for the non-transactional MongoDB store with the transactionlife-cycle for the relational database.8.1 Cross Store ConfigurationAssuming that you have a working JPA application and would like to add some cross-store persistencefor MongoDB. What do you have to add to your configuration?First of all you need to add a dependency on the spring-data-mongodb-cross-store module.Using Maven this is done by adding a dependency to your pom:4.0.0...org.springframework.dataspring-data-mongodb-cross-store${spring.data.mongo.version}...Example 8.1 Example Maven pom.xml with spring-data-mongodb-cross-store dependencyOnce this is done we need to enable AspectJ for the project. The cross-store support is implementedusing AspectJ aspects so by enabling compile time AspectJ support the cross-store features will becomeavailable to your project. In Maven you would add an additional plugin to the section of the pom:1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 88

please define productname in your docbook file!8. Cross Store supportSometimes you need to store data in multiple data stores and these data stores can be of differenttypes. One might be relational while the other a document store. For this use case we have created aseparate module in the <strong>MongoDB</strong> support that handles what we call cross-store support. The currentimplemenatation is based on JPA as the driver for the relational database and we allow select fields inthe Entities to be stored in a Mongo database. In addition to allowing you to store your data in two storeswe also coordinate persistence operations for the non-transactional <strong>MongoDB</strong> store with the transactionlife-cycle for the relational database.8.1 Cross Store ConfigurationAssuming that you have a working JPA application and would like to add some cross-store persistencefor <strong>MongoDB</strong>. What do you have to add to your configuration?First of all you need to add a dependency on the spring-data-mongodb-cross-store module.Using Maven this is done by adding a dependency to your pom:4.0.0...org.springframework.dataspring-data-mongodb-cross-store${spring.data.mongo.version}...Example 8.1 Example Maven pom.xml with spring-data-mongodb-cross-store dependencyOnce this is done we need to enable AspectJ for the project. The cross-store support is implementedusing AspectJ aspects so by enabling compile time AspectJ support the cross-store features will becomeavailable to your project. In Maven you would add an additional plugin to the section of the pom:1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 88

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

Saved successfully!

Ooh no, something went wrong!