title: Get reference to parent document from embedded document in Spring Data MongoDB
body: <p>I'd like to have access to the parent object from an embedded object, but can't find a way to do it. I'll show here an example of what this means:</p>
  
  <p>I have 2 Java classses like this:</p>
  
  <pre><code>@Document    
  public class Parent {
    private String name;
    private List&lt;Child&gt; children;
  
    @PersistenceConstructor
    public Parent (String name, List&lt;Child&gt; children) {
      this.name = name;
      this.children = children;
    }
  
  ...
  
  @Document
  public class Child {
    private String name;
    private Parent parent;
  
    @PersistenceConstructor
    public Child(String name, Parent parent) {
      this.name = name;
      this.parent = parent;
    }
    ...
  </code></pre>
  
  <p>My document in MongoDB is like this:</p>
  
  <pre><code>{
    "name": "some name",
    "children" : {
      "name": "name1"
    },
    {
      "name" : "name2"
    }
  }
  </code></pre>
  
  <p>Is it somehow possible to get reference to the parent, for example in the constructor in Child class? It seems that all the parameters in @PersistenceConstructor annotated constructor in Child class have to come from the children array, which means that the parameter named parent comes as null :(</p>
  
  <p>I know that if I create my own Converter implementation, I could just de-serialize Parent and Child and set the parent reference to child myself, but my actual document is quite big and having to write the de-serialization code myself would be a lot of boiler-plate code.</p>