title: Missing collections in entities using Hibernate OGM with mongodb
body: <p>The collections in my entities don't get persisted, whether it's a simple collection or association.<br>
  I'm using OGM with mongodb.</p>
  
  <p>For an example of the problem consider the following entities:</p>
  
  <pre><code>@Entity
  class Document {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Type(type = "objectid")
      String id;
  
      String name;
  
      @ElementCollection
      Set&lt;String&gt; names;
  
      Document() {
          this.names = new HashSet&lt;&gt;();
      }
  
      Document(String name) {
          this();
          this.name = name;
      }
  }
  
  @Entity
  class ChildDocument {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Type(type = "objectid")
      String id;
  
      String name;
  
      ChildDocument() {}
  
      ChildDocument(String name) {
          this.name = name;
      }
  }
  
  class ParentDocument {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      @Type(type = "objectid")
      String id;
  
      int count;
  
      @OneToMany(cascade = CascadeType.ALL)
      @AssociationStorage(AssociationStorageType.IN_ENTITY)
      List&lt;ChildDocument&gt; kids = new LinkedList&lt;&gt;();
  }
  </code></pre>
  
  <p>The following setup:</p>
  
  <pre><code>final StandardServiceRegistryBuilder registryBuilder = new StandardServiceRegistryBuilder()
          .applySetting(OgmProperties.ENABLED, true)
          .applySetting(AvailableSettings.TRANSACTION_COORDINATOR_STRATEGY, "jta")
          .applySetting(AvailableSettings.JTA_PLATFORM, "JBossTS")
          .applySetting(OgmProperties.DATASTORE_PROVIDER, MongoDB.DATASTORE_PROVIDER_NAME)
          .applySetting(OgmProperties.DATABASE, "testdb")
          .applySetting(OgmProperties.CREATE_DATABASE, "true");
  
  final StandardServiceRegistry registry = registryBuilder.build();
  final MetadataSources sources = new MetadataSources(registry);
  sources.addAnnotatedClass(Document.class);
  sources.addAnnotatedClass(ChildDocument.class);
  sources.addAnnotatedClass(ParentDocument.class);
  
  final SessionFactory sessionFactory = sources.buildMetadata().getSessionFactoryBuilder()
          .unwrap(OgmSessionFactoryBuilder.class)
          .build();
  </code></pre>
  
  <p>And this short program:</p>
  
  <pre><code>Document document1 = new Document("one");
  Document document2 = new Document("two");
  document2.names.add("one.one");
  document2.names.add("one.two");
  
  ParentDocument parent = new ParentDocument();
  parent.count = 2;
  parent.kids.add(new ChildDocument("one"));
  parent.kids.add(new ChildDocument("two"));
  
  final Session session = sessionFactory.openSession();
  session.save(document1);
  session.save(document2);
  session.save(parent);
  session.close();
  
  sessionFactory.close();
  </code></pre>
  
  <p>The <code>testdb</code> now contains 3 collections: <code>Document</code>, <code>ChildDocument</code> and <code>ParentDocument</code>.  </p>
  
  <ul>
  <li>The <code>ChildDocument</code> documents are correct as they only need to have the <code>_id</code> and <code>name</code>  </li>
  <li>The <code>Document</code> documents also contain only the <code>_id</code> and <code>name</code>, the <code>names</code> collection is missing</li>
  <li>In <code>ParentDocument</code> only the <code>_id</code> and <code>count</code> are persisted but the reference to the kids is missing even though the <code>ChildDocuments</code> are created</li>
  </ul>
  
  <p>What am I doing wrong?<br>
  Thanks</p>