title: NullPointerException while using MongoTemplate in Spring boot
body: <p>I have a collection named 'statusbynumbers' and I define the entity like this:</p>
  
  <pre><code>@Document(collection="statusbynumbers") 
  @Data
  @AllArgsConstructor
  @NoArgsConstructor
  public class StatusByNumbersEntity {
      @Id
      private String id;
  
      @Field("number")
      private String number;
  
      @Field("level")
      private String 
  
      @Field("yat")
      private double yat;
  }
  </code></pre>
  
  <p>the key 'yat' is a double type in the db. But in my business logic, in some cases, 'yat' can be null. Then when I uses MongoTemplate.find() method, java.lang.NullPointerException: null was caused. The MongoTemplate.find() used in my code shown as below:</p>
  
  <pre><code>public class ReportsServiceImpl implements ReportsService {
      @Resource
      private MongoTemplate ReportsMongoTemplate;
  
      @Override
      public List&lt;StatusByNumbersEntity&gt; getNumbersByFilterLevel(String filterLevel) {
          List&lt;Integer&gt; filterLevelList = FilterLevelModel.buildFilterLevel(filterLevel);
  
          Criteria criteria = Criteria.where("level").in(filterLevelList);
          Query query = new Query(criteria);
          // java.lang.NullPointerException: null caused by the following code
          List&lt;StatusByNumbersEntity&gt; numList = ReportsMongoTemplate.find(query,StatusByNumbersEntity.class); 
  
      ...
  }
  </code></pre>
  
  <p>The detailed error log shown as below</p>
  
  <pre><code>    2017-10-10 02:47:06.475 ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is
  java.lang.NullPointerException] with root cause
  java.lang.NullPointerException: null
  at sun.invoke.util.ValueConversions.unboxDouble(ValueConversions.java:139)
  at com.test.application.entities.reports.numbersEntity_Accessor_22t0xt.setProperty(Unknown Source)
  at org.springframework.data.mapping.model.ConvertingPropertyAccessor.setProperty(ConvertingPropertyAccessor.java:58)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:291)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter$1.doWithPersistentProperty(MappingMongoConverter.java:279)
  at org.springframework.data.mapping.model.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:330)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:279)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:239)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:199)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:195)
  at org.springframework.data.mongodb.core.convert.MappingMongoConverter.read(MappingMongoConverter.java:85)
  at org.springframework.data.mongodb.core.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:2324)
  at org.springframework.data.mongodb.core.MongoTemplate.executeFindMultiInternal(MongoTemplate.java:1969)
  at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1787)
  at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1770)
  at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:644)
  at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:635)
  </code></pre>
  
  <p>How can i use the MongoTemplate.find() method even if the key "yat" can be null instead of double type to avoid this NullPointerException? </p>