title: spring data mongodb mapping dynamic field
body: <p>I've this model in my java class</p>
  
  <pre><code>@Document
  public class Template {
  
      private String type;
  
      private String code;
  
      @Version
      Long version;
  }
  </code></pre>
  
  <p>I need to add a new field, named <em>template</em>, and map this field as dynamic in other words I would model a document like this</p>
  
  <pre><code>{
    _id: 'id' 
    type:'myType',
    code:'myCode'
    template:{
      someFiled:[
        {
          subField1:'value1',
          subField2:'value2'
        },
        {
          sub1Field1:'1value1',
          sub1Field2:'1value2'
        }
        .......................
      ],
      otherField:[
        {
          otherField1:'value1',
          otherField2:'value2'
        }
      ],
      .........
    },
    version:1000L
  }
  </code></pre>
  
  <p>There is any way to annotated a field as dynamic?</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <pre><code>    @Document
      public class Template {
  
          private String type;
  
          private String code;
  
          private Map&lt;String, Object&gt; template;
  
          @Version
          Long version;
      }
  </code></pre>