title: mongodb query with spring data for key-value
body: <p>I've been started a project with mongodb and spring boot and spring JPA data and I realised I cannot map my data model to entity and make a query on that easily, so I have two questions,</p>
  
  <p>My data model is like that ( just for one Collection )</p>
  
  <pre><code>{
     name: "Name",
     lastName: "Last Name",
     attributes: {
        age: 25
        eye: {
           color: "RED",
           size: "BIG"
        }
     }
  }
  </code></pre>
  
  <p>And my entity is</p>
  
  <pre><code>@Entity // or @Document
  public class User{
     private String name;
     private String lastName;
     private Map&lt;String, ?&gt; attributes = new HashMap&lt;&gt;();
  
     // id or the setter getter are omitted
  }
  </code></pre>
  
  <ol>
  <li>Can I map attributes property in my mongodb collection like I did ( Map )</li>
  <li><p>How can I make query for finding the attributes? </p>
  
  <p>Can I do it like that?
  <code>List&lt;User&gt; findAllByAttributesAge(Integer age);</code></p></li>
  </ol>