Spring Data MongoDB - Spring Web Services - Parent - SpringSource
Spring Data MongoDB - Spring Web Services - Parent - SpringSource Spring Data MongoDB - Spring Web Services - Parent - SpringSource
please define productname in your docbook file!package com.mycompany.domain;@Documentpublic class Person {@Idprivate ObjectId id;@Indexedprivate Integer ssn;private String firstName;@Indexedprivate String lastName;}Example 7.3 Example domain objectImportantThe @Id annotation tells the mapper which property you want to use for the MongoDB _idproperty and the @Indexed annotation tells the mapping framework to call ensureIndex onthat property of your document, making searches faster.Mapping annotation overviewThe MappingMongoConverter can use metadata to drive the mapping of objects to documents. Anoverview of the annotations is provided below• @Id - applied at the field level to mark the field used for identiy purpose.• @Document - applied at the class level to indicate this class is a candidate for mapping to thedatabase. You can specify the name of the collection where the database will be stored.• @DBRef - applied at the field to indicate it is to be stored using a com.mongodb.DBRef.• @Indexed - applied at the field level to describe how to index the field.• @CompoundIndex - applied at the type level to declare Compound Indexes• @GeoSpatialIndexed - applied at the field level to describe how to geoindex the field.• @Transient - by default all private fields are mapped to the document, this annotation excludes thefield where it is applied from being stored in the database• @PersistenceConstructor - marks a given constructor - even a package protected one - to usewhen instantiating the object from the database. Constructor arguments are mapped by name to thekey values in the retrieved DBObject.• @Value - this annotation is part of the Spring Framework . Within the mapping framework it canbe applied to constructor arguments. This lets you use a Spring Expression Language statementto transform a key's value retrieved in the database before it is used to construct a domainobject. In order to reference a property of a given document one has to use expressions like:@Value("#root.myProperty") where root refers to the root of the given document.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 81
please define productname in your docbook file!• @Field - applied at the field level and described the name of the field as it will be represented in theMongoDB BSON document thus allowing the name to be different than the fieldname of the class.The mapping metadata infrastructure is defined in a seperate spring-data-commons project that istechnology agnostic. Specific subclasses are using in the MongoDB support to support annotation basedmetadata. Other strategies are also possible to put in place if there is demand.Here is an example of a more complex mapping.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 82
- Page 36 and 37: please define productname in your d
- Page 38 and 39: please define productname in your d
- Page 40 and 41: please define productname in your d
- Page 42 and 43: please define productname in your d
- Page 44 and 45: please define productname in your d
- Page 46 and 47: please define productname in your d
- Page 48 and 49: please define productname in your d
- Page 50 and 51: please define productname in your d
- Page 52 and 53: please define productname in your d
- Page 54 and 55: please define productname in your d
- Page 56 and 57: please define productname in your d
- Page 58 and 59: please define productname in your d
- Page 60 and 61: please define productname in your d
- Page 62 and 63: please define productname in your d
- Page 64 and 65: please define productname in your d
- Page 66 and 67: please define productname in your d
- Page 68 and 69: please define productname in your d
- Page 70 and 71: please define productname in your d
- Page 72 and 73: please define productname in your d
- Page 74 and 75: please define productname in your d
- Page 76 and 77: please define productname in your d
- Page 78 and 79: please define productname in your d
- Page 80 and 81: please define productname in your d
- Page 82 and 83: please define productname in your d
- Page 84 and 85: please define productname in your d
- Page 88 and 89: please define productname in your d
- Page 90 and 91: please define productname in your d
- Page 92 and 93: please define productname in your d
- Page 94 and 95: please define productname in your d
- Page 96 and 97: please define productname in your d
- Page 98 and 99: please define productname in your d
- Page 100 and 101: please define productname in your d
- Page 102 and 103: please define productname in your d
- Page 104: please define productname in your d
please define productname in your docbook file!• @Field - applied at the field level and described the name of the field as it will be represented in the<strong>MongoDB</strong> BSON document thus allowing the name to be different than the fieldname of the class.The mapping metadata infrastructure is defined in a seperate spring-data-commons project that istechnology agnostic. Specific subclasses are using in the <strong>MongoDB</strong> support to support annotation basedmetadata. Other strategies are also possible to put in place if there is demand.Here is an example of a more complex mapping.1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 82