title: Spring Common Data 2.1.2 MongoDB can't deserialise Optional value
body: <p>Spring Common Data 2.1.2 (and Data MongoDB 2.1.2) cannot deserialise Optional field from my class.
  It worked with previous version (2.0.8), now my object is saved in DB (with MongoRepository.save),
  but there is an exception when i try to read it (MongoRepository.findById).
  I've narrowed down an exact field and the problem is with storing Optional:</p>
  
  <pre><code>java.lang.UnsupportedOperationException: Cannot set immutable property java.util.Optional.value!
      at org.springframework.data.mapping.model.BeanWrapper.setProperty(BeanWrapper.java:86) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
      at org.springframework.data.mapping.model.ConvertingPropertyAccessor.setProperty(ConvertingPropertyAccessor.java:61) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELE
  </code></pre>
  
  <p>and my class:</p>
  
  <p>public class Coordinates {
      private double latitude;
      private double longitude;
      private Optional altitude;
  }</p>
  
  <p>there is an exception when data in DB is in a form:</p>
  
  <pre><code>altitude: Object
     value: 0
  </code></pre>
  
  <p>and no error when altitude doesn't have a 'value'</p>
  
  <pre><code>altitude: Object
  </code></pre>
  
  <p>(no value)</p>
  
  <p>It worked with previous Spring Boot version (and Spring Data Commons/Mongodb 2.0.8).</p>
  
  <p>I can't find any information about changed behaviour/different handling of Optionals etc.</p>
  
  <p>How to solve it ?</p>
  
  <p>Should i keep it as </p>
  
  <pre><code>private Double altitude;
  </code></pre>
  
  <p>with getter:</p>
  
  <pre><code>public Optional&lt;Double&gt; getAltitude() {
      return Optional.ofNullable(altitude);
  }
  </code></pre>
  
  <p>or any other way ?</p>