anchor.diff:      @Id
       private String id;
   
  +    private String SSN;
  +
       @ManyToMany
  -    public Set<BankAccount> bankAccounts;
  -
  -    //getters, setters, ...
  -}
  -----
  -====
  -
  -.JSON representation
  -====
  -[source, JSON]
  -----
  -{
  -    "_id" : "owner0001",
  -    "bankAccounts" : [
  -        "accountABC",
  -        "accountXYZ"
  -    ]
  -}
  -----
  -====
  -
  -====== Global collection strategy
  -
  -With this strategy, Hibernate OGM creates a single collection
  -in which it will store all navigation information for all associations.
  -Each document of this collection is structure in 2 parts.
  -The first is the +_id+ field which contains the identifier information
  -of the association owner and the name of the association table.
  -The second part is the +rows+ field which stores (into an embedded collection) all ids
  -that the current instance is related to.
  -
  -.Unidirectional relationship
  -====
  -[source, JSON]
  -----
  -{
  -    "_id": {
  -        "owners_id": "owner0001",
  -        "table": "AccountOwner_BankAccount"
  -    },
  -    "rows": [
  -        "accountABC",
  -        "accountXYZ"
  -    ]
  -}
  -----
  -====
  -
  -For a bidirectional relationship, another document is created where ids are reversed.
  -Don't worry, Hibernate OGM takes care of keeping them in sync:
  -
  -.Bidirectional relationship
  -====
  -[source, JSON]
  -----
  -{
  -    "_id": {
  -        "owners_id": "owner0001",
  -        "table": "AccountOwner_BankAccount"
  -    },
  -    "rows": [
  -        "accountABC",
  -        "accountXYZ"
  -        ]
  -}
  -{
  -    "_id": {
  -        "bankAccounts_id": "accountXYZ",
  -        "table": "AccountOwner_BankAccount"
  -    },
  -    "rows": [
  -        "owner0001"
  -    ]
  -}
  -----
  -====
  -
  +    private Set<BankAccount> bankAccounts;
  +
  +    // getters, setters ...
  +}
  +
  +@Entity
  +public class BankAccount {
  +
  +    @Id
  +    private String id;
  +
  +    private String accountNumber;
  +
  +    @ManyToMany( mappedBy = "bankAccounts" )
  +    private Set<AccountOwner> owners = new HashSet<AccountOwner>();
  +
  +    // getters, setters ...
  +}
  +----
  +
  +AccountOwner collection
  +
  +[source, JSON]
  +----
  +{
  +    "_id" : "owner_1",
  +    "SSN" : "0123456"
  +    "bankAccounts" : [ "account_1" ]
  +}
  +----
  +
  +BankAccount collection
  +
  +[source, JSON]
  +----
  +{
  +    "_id" : "account_1",
  +    "accountNumber" : "X2345000"
  +    "owners" : [ "owner_1", "owner2222" ]
  +}
  +----
  +====
  +
  +[[mongodb-collection-per-association-strategy]]
   ====== One collection per association strategy
   
   In this strategy, Hibernate OGM creates a MongoDB collection per association
   in which it will store all navigation information for that particular association.
  +
   This is the strategy closest to the relational model.
   If an entity A is related to B and C, 2 collections will be created.
   The name of this collection is made of the association table concatenated with +associations_+.
  +
   For example, if the [classname]+BankAccount+ and [classname]+Owner+ are related,
  -the collection used to store will be named +associations_Owner_BankAccount+.
  +the collection used to store will be named +associations_Owner_BankAccount+. You can rename
   The prefix is useful to quickly identify the association collections from the entity collections.
  +You can also decide to rename the collection representing the association using +@JoinTable+
  +(see <<mongodb-one-collection-strategy-join-table, an example>>) 
  +
   Each document of an association collection has the following structure:
   
   * +_id+ contains the id of the owner of relationship
   * +rows+ contains all the id of the related entities
  +
  +[NOTE]
  +====
  +The preferred approach is to use the <<mongodb-in-entity-strategy, in-entity strategy>>
  +but this approach can alleviate the problem of having documents that are too big.
  +====
   
   .Unidirectional relationship
   ====
  
positive.code: ----
  ====
  
  ===== Associations
  
  Hibernate OGM MongoDB proposes three strategies to store navigation information for associations.
  To switch between these strategies,
  either use the +@AssocationStorage+ and +@AssociationDocumentStorage+ annotations (see <<ogm-mongodb-annotation-configuration>>),
  the API for programmatic configuration (see <<ogm-mongodb-programmatic-configuration>>) or
  specify a default strategy via the +hibernate.ogm.datastore.document.association_storage+ and
  +hibernate.ogm.mongodb.association_document_storage+ configuration properties.
  
  The three possible strategies are:
  
  * IN_ENTITY (default)
  * ASSOCIATION_DOCUMENT, using a global collection for all associations
  * ASSOCIATION_DOCUMENT, using a dedicated collection for each association
  
  ====== In Entity strategy
  
  In this strategy, Hibernate OGM directly stores the id(s)
  of the other side of the association
  into a field or an embedded document
  depending if the mapping concerns a single object or a collection.
  The field that stores the relationship information is named like the entity property.
  
  .Java entity
  ====
  [source, JAVA]
  ----
  
negative.code: to offer various classic mappings between your object model
  and the MongoDB documents.
  
  [[mongodb-built-in-types]]
  ===== Builtin types
  
  Hibernate OGM supports by default the following types:
  
  * [classname]+java.lang.String+
  
  [source, JSON]
  ----
    { "text" : "Hello world!" }
  ----
  
  * [classname]+java.lang.Boolean+ (or boolean primitive)
  
  [source, JSON]
  ----
    { "favorite" : true }
  ----
  
  * [classname]+java.lang.Byte+ (or byte primitive)
  
  [source, JSON]
  ----
    { "display_mask" : "70" }
  ----
  
  * [classname]+java.lang.Long+ (or long primitive)
  
  [source, JSON]
  ----
    { "userId" : NumberLong("-6718902786625749549") }
  ----
  
  * [classname]+java.lang.Integer+ (or integer primitive)
  
  [source, JSON]
  ----
    { "stockCount" : 12309 }
  ----
  
  * [classname]+java.lang.Double+ (or double primitive)
  
  [source, JSON]
  ----
    { "tax_percentage" : 12.34 }
  ----
  
  * [classname]+java.math.BigDecimal+
  
  [source, JSON]
  ----
    { "site_weight" : "21.77" }
  ----
  
  * [classname]+java.math.BigInteger+
  
  [source, JSON]
  ----
    { "site_weight" : "444" }
  ----
  
  * [classname]+java.util.Calendar+
  
  [source, JSON]
  ----
    { "creation" : "2014/11/03 16:19:49:283 +0000" }
  ----
  
  * [classname]+java.util.Date+
  
  [source, JSON]
  ----
    { "last_update" : ISODate("2014-11-03T16:19:49.283Z") }
  ----
  
  * [classname]+java.util.UUID+
  
  [source, JSON]
  ----
    { "serialNumber" : "71f5713d-69c4-4b62-ad15-aed8ce8d10e0" }
  ----
  
  * [classname]+java.util.URL+
  
  [source, JSON]
  ----
    { "url" : "http://www.hibernate.org/" }
  ----
  
  * [classname]+java.util.URL+
  
  [source, JSON]
  ----
    { "url" : "http://www.hibernate.org/" }
  ----
  
  * [classname]+java.util.URL+
  
  [source, JSON]
  ----
    { "url" : "http://www.hibernate.org/" }
  ----
  
  * [classname]+org.bson.types.ObjectId+
  
  [source, JSON]
  ----
    { "object_id" : ObjectId("547d9b40e62048750f25ef77") }
  ----
  
  ===== Entities
  
  Entities are stored as MongoDB documents and not as BLOBs:
  each entity property will be translated into a document field.
  You can use [classname]+@Table+ and [classname]+@Column+ annotations
  to rename respectively the collection the document is stored in
  and the document's field a property is persisted in.
  
  .Default JPA mapping for an entity
  ====
  [source, JAVA]
  ----
  @Entity
  public class News {
  
      @Id
      private String id;
      private String title;
  
      // getters, setters ...
  }
  ----
  
  [source, JSON]
  ----
  // Stored in the Collection "News"
  {
      "_id" : "1234-5678-0123-4567",
      "title": "On the merits of NoSQL",
  }
  ----
  ====
  
  .Rename field and collection using @Table and @Column
  ====
  [source, JAVA]
  ----
  @Entity
  // Overrides the collection name
  @Table(name = "News_Collection")
  public class News {
  
      @Id
      private String id;
  
      // Overrides the field name
      @Column(name = "headline")
      private String title;
  
      // getters, setters ...
  }
  ----
  
  [source, JSON]
  ----
  // Stored in the Collection "News"
  {
      "_id" : "1234-5678-0123-4567",
      "headline": "On the merits of NoSQL",
  }
  ----
  ====
  
  ====== Identifiers
  
  [NOTE]
  ====
  Hibernate OGM always store identifiers using the +_id+ field of a MongoDB document ignoring
  the name of the property in the entity.
  ====
  
  An identifier type may be one of the <<mongodb-built-in-types,built-in types>>
  or a more complex type represented by an embedded class.
  When you use a built-in type, the identifier is mapped like a regular property.
  When you use an embedded class, then the `_id` is representing a nested document
  containing the embedded class properties.
  
  .Define an identifier as a primitive type
  ====
  [source, JAVA]
  ----
  @Entity
  public class Bookmark {
  
      @Id
      private String id;
  
      private String title;
  
      // getters, setters ...
  }
  ----
  
  [source, JSON]
  ----
  {
    "_id" : "bookmark_1" 
    "title" : "Hibernate OGM documentation"
  }
  ----
  ====
  
  .Define an identifier using @EmbeddedId
  ====
  [source, JAVA]
  ----
  @Embeddable
  public class NewsID implements Serializable {
  
      private String title;
      private String author;
  
      // getters, setters ...
  }
  
  @Entity
  public class News {
  
      @EmbeddedId
      private NewsID newsId;
      private String content;
  
      // getters, setters ...
  }
  ----
  
  News collection as JSON in MongoDB
  
  [source, JSON]
  ----
  
  {
    "_id" : {
        "author" : "Guillaume",
        "title" : "How to use Hibernate OGM ?"
    },
    "content" : "Simple, just like ORM but with a NoSQL database"
  }
  
  ----
  ====
  
  Generally, it is recommended though to work with MongoDB's object id data type.
  This will facilitate the integration with other applications expecting that common MongoDB id type.
  To do so, you have two options:
  
  * Define your id property as +org.bson.types.ObjectId+
  * Define your id property as +String+ and annotate it with +@Type(type="objectid")+
  
  In both cases the id will be stored as native +ObjectId+ in the datastore.
  
  .Define an id as ObjectId
  ====
  [source, JAVA]
  ----
  @Entity
  public class News {
  
      @Id
      private ObjectId id;
  
      private String title;
  
      // getters, setters ...
  }
  ----
  ====
  
  .Define an id of type String as ObjectId
  ====
  [source, JAVA]
  ----
  @Entity
  public class News {
  
      @Id
      @Type(type = "objectid")
      private String id;
  
      private String title;
  
      // getters, setters ...
  }
  ----
  ====
  
  ====== Identifier generation strategies
  
  You can assign id values yourself or let Hibernate OGM generate the value using the
  [classname]+@GeneratedValue+ annotation.
  
  There are 4 different strategies:
  
  1. <<mongodb-identity-id-generation-strategy, IDENTITY>> (suggested)
  2. <<mongodb-table-id-generation-strategy, TABLE>>
  3. <<mongodb-sequence-id-generation-strategy, SEQUENCE>>
  4. <<mongodb-auto-id-generation-strategy, AUTO>>
  
  [[mongodb-identity-id-generation-strategy]]
  *1) IDENTITY generation strategy*
  
  The preferable strategy, Hibernate OGM will create the identifier upon insertion.
  To apply this strategy the id must be one of the following:
  
  * annotated with +@Type(type="objectid")+
  * [classname]+org.bson.types.ObjectId+ 
  
  like in the following examples:
  
  .Define an id of type String as ObjectId
  ====
  [source, JAVA]
  ----
  