title: Cannot read or serialize POJO with enumerations using Java MongoDB driver
body: <p>I have an existing object that I want to serialize in MongoDB using Java + POJO codec. For some reason the driver tries to create an instance of an enum instead of using valueOF:</p>
  
  <pre><code>org.bson.codecs.configuration.CodecConfigurationException: Failed to decode 'phase'. Failed to decode 'value'. Cannot find a public constructor for 'SimplePhaseEnumType'.
  at org.bson.codecs.pojo.PojoCodecImpl.decodePropertyModel(PojoCodecImpl.java:192)
  at org.bson.codecs.pojo.PojoCodecImpl.decodeProperties(PojoCodecImpl.java:168)
  at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:122)
  at org.bson.codecs.pojo.PojoCodecImpl.decode(PojoCodecImpl.java:126)
  at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:52)
  </code></pre>
  
  <p>The enumeration:</p>
  
  <pre><code>public enum SimplePhaseEnumType {
  
  PROPOSED("Proposed"),
  INTERIM("Interim"),
  MODIFIED("Modified"),
  ASSIGNED("Assigned");
  private final String value;
  
  SimplePhaseEnumType(String v) {
      value = v;
  }
  
  public String value() {
      return value;
  }
  
  public static SimplePhaseEnumType fromValue(String v) {
      for (SimplePhaseEnumType c: SimplePhaseEnumType.values()) {
          if (c.value.equals(v)) {
              return c;
          }
      }
      throw new IllegalArgumentException(v);
  }}
  </code></pre>
  
  <p>And the class the uses the enumeration (only showing the relevant fields):</p>
  
  <pre><code>public class SpecificPhaseType {
  
  protected SimplePhaseEnumType value;
  protected String date;
  
  public SimplePhaseEnumType getValue() {
      return value;
  }
  
  public void setValue(SimplePhaseEnumType value) {
      this.value = value;
  }}
  </code></pre>
  
  <p>I was looking for a way to maybe annotate the class to tell the driver to use a different method to serialize / deserialize those fields when they are encountered. I know how to skip them during the serialization / deserialization but that doesn't fix the problem:</p>
  
  <pre><code>public class SpecificPhaseType {
  
  @BsonIgnore
  protected SimplePhaseEnumType value;
  </code></pre>
  
  <p>Any help on where I could look (code, documentation)?. I already checked <a href="https://github.com/mongodb/mongo-java-driver/blob/master/driver-async/src/examples/tour/PojoQuickTour.java" rel="nofollow noreferrer">PojoQuickTour.java</a>, <a href="http://mongodb.github.io/mongo-java-driver/3.6/driver/getting-started/quick-start-pojo/#creating-a-custom-codecregistry" rel="nofollow noreferrer">MongoDB Driver Quick Start - POJOs</a> and <a href="http://mongodb.github.io/mongo-java-driver/3.6/bson/pojos/" rel="nofollow noreferrer">POJOs - Plain Old Java Objects</a></p>
  
  <p>Thanks!</p>
  
  <p>--Jose</p>