title: Cannot autogenerate id of type java.lang.Long for entity of type Entity - Mongodb and Spring Boot
body: <p>I'm trying to send a POST method to mongoDB but I get Cannot autogenerate id of type java.lang.Long for entity of type Entity</p>
  <p>Here is my Entity:</p>
  <pre><code>@Data
  @AllArgsConstructor
  @Document(collection = &quot;TaxesLine&quot;)
  public class TaxesligneEntity {
  
  
  
      @Id
      private Long taxesLigneId;
      private Date dateReception;
      private String label;
      private int nbrLignes;
      private int nbrOperationW;
      private int nbrOperationV;
      private BigDecimal initalSol;
      private BigDecimal finalSol;
      private List&lt;LigneEntity&gt; lignes;
  
  
  
      public TaxesligneEntity(){
          super();
      }
  }
  </code></pre>
  <p>Here is my POST method:</p>
  <pre><code>{
    &quot;taxesLigneId&quot;: 1200,
    &quot;dateReception&quot;: &quot;2022-03-04T01:17:59.344Z&quot;,
    &quot;label&quot;: &quot;5488&quot;,
    &quot;nbrLignes&quot;: 541,
    &quot;nbrOperationW&quot;: 4521,
    &quot;nbrOperationV&quot;: 5421,
    &quot;initalSol&quot;: 541,
    &quot;finalSol&quot;: 0,
    &quot;lignes&quot;: [
      {
        &quot;lignesId&quot;: 54,
        &quot;dateOperation&quot;: &quot;2022-03-04T01:17:59.345Z&quot;,
        &quot;operationNature&quot;: &quot;string&quot;,
        &quot;ert&quot;: &quot;string&quot;,
        &quot;numC&quot;: 0,
        &quot;ammout&quot;: 0,
        &quot;CD&quot;: 0,
        &quot;rC&quot;: 0,
        &quot;rF&quot;: 0,
        &quot;paymentM&quot;: &quot;string&quot;,
        &quot;operationC&quot;: {
          &quot;OperationD&quot;: &quot;2022-03-04T01:17:59.345Z&quot;,
          &quot;operationCh&quot;: {
            &quot;numCh&quot;: 54,
            &quot;cheq&quot;: {
              &quot;numCh&quot;: 88,
              &quot;acteur&quot;: {
                &quot;nActeur&quot;: &quot;string&quot;,
                &quot;pActeur&quot;: &quot;string&quot;
              }
            }
          },
          &quot;operationEs&quot;: {
            &quot;pwa&quot;: &quot;string&quot;,
            &quot;nomEm&quot;: &quot;string&quot;,
            &quot;preEm&quot;: &quot;string&quot;
          },
          &quot;operationV&quot;: {
            &quot;pwa&quot;: &quot;string&quot;,
            &quot;compB&quot;: {
              &quot;rcinb&quot;: &quot;string&quot;,
              &quot;Swift&quot;: &quot;string&quot;,
              &quot;ban&quot;: {
                &quot;nomBan&quot;: &quot;string&quot;
              },
              &quot;acteur&quot;: {
                &quot;nAct&quot;: &quot;string&quot;,
                &quot;preAct&quot;: &quot;string&quot;
              }
            }
          },
          &quot;produit&quot;: {
            &quot;pId&quot;: 858,
            &quot;pCode&quot;: &quot;string&quot;,
            &quot;pLabel&quot;: &quot;string&quot;,
          }
        }
      }
    ]
  }
  </code></pre>
  <p>This is the error:</p>
  <pre><code>{
      &quot;timestamp&quot;: &quot;2022-03-04T12:03:33.755+0000&quot;,
      &quot;status&quot;: 500,
      &quot;error&quot;: &quot;Internal Server Error&quot;,
      &quot;message&quot;: &quot;Cannot autogenerate id of type java.lang.Long for entity of type rel.persistence.mongodb.entity.taxesLignesEntity!&quot;,
      &quot;path&quot;: &quot;/api/taxeslignes&quot;
  }
  </code></pre>
  <p>I tried String and Integer as an id it passes but fields are null + not all fields persisted here is the result of changing to String and Integer</p>
  <pre><code>&quot;taxesLigneId&quot;: null,
        &quot;dateReception&quot;: &quot;null&quot;,
        &quot;label&quot;: &quot;0&quot;,
        &quot;initalSol&quot;: 0,
        &quot;finalSol&quot;: 0,
  </code></pre>