title: Mongo Cannot cast Hashmap to BasicDBObject
body: <p>I've been working on a java program that makes use of a Mongo database to store certain data about airplanes based on geo coordinates. The application is working to the point as where it is gathering the information and filling up the model objects in the correct way.</p>
  
  <p>When I try to send the object towards the mongo database I get the following error: <code>java.lang.ClassCastException: java.util.hashmap cannot be cast to com.mongodb.basicDbObject.</code> The problem with this exception: I don't have a HashMap (or any type of Map in general)</p>
  
  <p>To add the object to the database I use the following code:</p>
  
  <pre><code>DBCollection table = db.getCollection(GRID_NAME);
  GridCell c = cell.getCell(true);
  String jString = (String) mapper.writeValueAsString(c); //mapper is a Jackson ObjectMapper
  System.out.println(jString);
  table.insert((BasicDBObject) JSON.parse(jString));
  </code></pre>
  
  <p>In here the grid cell contains two floats and a List of Plane objects. The plane object contains one string and another 10 double values. Other then that the classes only have basic getters and setters for all variables.</p>
  
  <p><strong>GridCell</strong></p>
  
  <pre><code>private float lat;
  private float lng;
  private List&lt;Plane&gt; planeList;
  </code></pre>
  
  <p><strong>Plane</strong></p>
  
  <pre><code>private String identiefier;
  private double minHeight;
  private double maxHeight;
  private double avgHeight;
  private double minSpeed;
  private double maxSpeed;
  private double avgSpeed;
  private double minCourse;
  private double maxCourse;
  private double avgCourse;
  </code></pre>
  
  <p><strong>A getter and setter (all look more or less the same as these two)</strong></p>
  
  <pre><code>public float getLng() {
      return lng;
  }
  
  public void setLng(float lng) {
      this.lng = lng;
  }
  </code></pre>
  
  <p>As you can see above I'm printing the json string to the console to check if it is correct. I have to admit my plain json reading skills are dodgy at best. But I can't find a hashmap in this:</p>
  
  <pre><code>{"lat":28.0,"lng":5.0,"planeList":[{"identifier":"myTestPlane","minHeight":1.0,"maxHeigh":2.0,"avgHeight":1.5,"minSpeed":1.0,"maxSpeed":2.0,"avgSpeed":1.5,"minCourse":1.0,"maxCourse":2.0,"avgCourse":1.5}]}
  </code></pre>
  
  <p>Any idea's or suggestions what I'm doing wrong? I might have a Monday morning moment but I really can't figure it out.</p>