title: How to save a Enum data in a POJO file to MongoDB
body: <p>I am able to save a Simple POJO file content in MongoDB using Gson, but now I want to save the enum data inside POJO file to MongoDB. But I am not getting how to save the enum data.</p>
  
  <p>This is my POJO file:</p>
  
  <pre><code>import javax.annotation.Generated;
  
  @Generated("org.jsonschema2pojo")
  public class Coverage1 {
      public  enum Coverage {
  Hearing_Aid_Professional_Liability("HEAR"), Incidental_Motorized_Land_Conveyances_Liability_Only("LANDC"), PremisesOperations_334("PREM"), Rental_Reimbursement("RREIM"), Liquor_Law_Liability_332("LLL"), Wind("WIND"), Business_Personal_Property("BPP"), OpticianOptometrists_Professional_Liability("OOPRL"), Builders_Risk("BLDRK");
  
      private String val;
  
  Coverage(String val){
          this.val = val;
      }
  
      public String getVal ()
      {
          return this.val;
      }
  
      public void setVal (String val)
      {
          this.val = val;
      }
  }
  
  
      private String id;
  
      private CoverageCd coverageCd;
      private CoverageDesc coverageDesc;
      private CoverageTypeCd coverageTypeCd;
  
      public String getId() {
          return id;
      }
  
  
      public void setId(String id) {
          this.id = id;
      }
  
  
      public CoverageCd getCoverageCd() {
          return coverageCd;
      }
  
  
      public void setCoverageCd(CoverageCd coverageCd) {
          this.coverageCd = coverageCd;
      }
  
  
      public CoverageDesc getCoverageDesc() {
          return coverageDesc;
      }
  
      public void setCoverageDesc(CoverageDesc coverageDesc) {
          this.coverageDesc = coverageDesc;
      }
  
  
      public CoverageTypeCd getCoverageTypeCd() {
          return coverageTypeCd;
      }
  
      public void setCoverageTypeCd(CoverageTypeCd coverageTypeCd) {
          this.coverageTypeCd = coverageTypeCd;
      }
  
  }
  </code></pre>
  
  <p>This is my class from where I am making Mongo Call</p>
  
  <pre><code>       Employee employee = new Employee(); // Create java object of Simple POJO with field No and Name
          employee.setNo(2L);
          employee.setName("POJO Test");
          Coverage1 cv= new Coverage1();//POJO containing Enum
          //How to save the Enum in Mongo
          // Deserialize object to json string
          Gson gson = new Gson();
          String json = gson.toJson(employee);
          System.out.println(json);
          // Parse to bson document and insert
         Document doc = Document.parse(json);
         db.getCollection("NameColl").insertOne(doc);
  </code></pre>
  
  <p>I am now able to get the values of Enum in another class, but not getting how to save the entire data in MongoDB.</p>
  
  <pre><code>Coverage1 cv= new Coverage1();
              for(Coverage1.Coverage enumval:Coverage1.Coverage.values()){
                  System.out.println(enumval);
                  cv.setValue(enumval);//How to set the entire Enum Data in Mongo
              }
  </code></pre>
  
  <p>Please suggest how can i insert the entire Enum data in MongoDB.</p>