title: Spring-Mongo : mapping mongo document field/s to BasicDBObject/Map of BasicDBObject of an Entity
body: <p>I have an entity <code>ProjectCycle</code> mapped to mongo DB collection <code>ProjectCycle</code>. I am trying to retrieve 2 fields, <code>_id</code> and <code>Status</code>. I am able to retrieve both like the following</p>
  
  <pre><code>@Document(collection="ProjectCycle")
  public class ProjectCycle {
      @Id
      private String id;
      @Field("Status")
      private String status;
  //getters and setters
  }
  </code></pre>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <pre><code>Application.java
  
      Query query = new Query();
      query.fields().include("Status");
      Criteria criteria = new Criteria();
      criteria.and("_id").is("1000");
      query.addCriteria(criteria);
      Iterable&lt;ProjectCycle&gt; objectList = mongoOperations.find(query, ProjectCycle.class);
      for(ProjectCycle obj : objectList) {
          System.out.println("_id "+obj.getId());
          System.out.println("status "+obj.getStatus());
      }
  </code></pre>
  
  <blockquote>
    <p>Output</p>
  </blockquote>
  
  <pre><code>_id 1000
  status Approved
  </code></pre>
  
  <p>But, the problem is when i use an Entity with field <code>private DBObject basicDbObject;</code> instead of <code>private String status;</code> i am getting value as <code>null</code> instead of <code>Approved</code></p>
  
  <p>I have tried like the following</p>
  
  <pre><code>public class ProjectCycle {
      @Id
      private String id;
      private DBObject basicDbObject;
      //getter &amp; setter
  }
  </code></pre>
  
  <p>What I am trying to achieve is that, the collection '<code>ProjectCycle</code>' is very large and creating a POJO corresponding to it is quiet difficult. Also I am only reading data from mongoDB. So creating the entire POJO is time wasting and tedious. </p>
  
  <ul>
  <li>How I can achieve mapping between any field/fields from mongo Collection to entity?. </li>
  <li>Will it be possible to create a <code>Map&lt;String, BasicDBObject&gt; objectMap;</code> to fields returned from query? I am using <code>Spring-data-mongodb</code> for the same.</li>
  </ul>
  
  <blockquote>
    <p>Version details</p>
    
    <p>Spring 4.0.7.RELEASE</p>
    
    <p>spring-data-mongodb 1.7.2.RELEASE</p>
  </blockquote>