13.07.2015 Views

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

Spring Data MongoDB - Spring Web Services - Parent - SpringSource

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

please define productname in your docbook file!Customer customer = new Customer();customer.setFirstName("Sven");customer.setLastName("Olafsen");SurveyInfo surveyInfo = new SurveyInfo().addQuestionAndAnswer("age", "22").addQuestionAndAnswer("married", "Yes").addQuestionAndAnswer("citizenship", "Norwegian");customer.setSurveyInfo(surveyInfo);customerRepository.save(customer);Example 8.6 Example of code using the JPA Entity configured for cross-store persistenceExecuting the code above results in the following JSON document stored in <strong>MongoDB</strong>.{ "_id" : ObjectId( "4d9e8b6e3c55287f87d4b79e" ),"_entity_id" : 1,"_entity_class" : "org.springframework.data.mongodb.examples.custsvc.domain.Customer","_entity_field_name" : "surveyInfo","questionsAndAnswers" : { "married" : "Yes","age" : "22","citizenship" : "Norwegian" },"_entity_field_class": "org.springframework.data.mongodb.examples.custsvc.domain.SurveyInfo" }Example 8.7 Example of JSON document stored in <strong>MongoDB</strong>1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 92

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

Saved successfully!

Ooh no, something went wrong!