title: Java spring data mongodb: UUID as entity ID in mongodb
body: <p>I'm building spring boot application with spring-boot-starter-data-mongodb:</p>
  
  <p>I have an etity which looks like:</p>
  
  <pre><code>@Document(collection = "nodes")
  @Data
  @Builder
  public class Node {
  
      @Id
      UUID id;
  
      String info;
  }
  </code></pre>
  
  <p>and repository interface:</p>
  
  <pre><code>public interface NodesRepository extends MongoRepository&lt;Node, UUID&gt; {
  }
  </code></pre>
  
  <p>The problem is that when I insert Node object with empty <code>id</code> field application throws exception with the following message: </p>
  
  <blockquote>
    <p>Cannot autogenerate id of type java.util.UUID for entity of type
    model.Node!</p>
  </blockquote>
  
  <p>I know that out of box spring mongodb  supports String and BigInteger id types for autogeneration. </p>
  
  <p>So I want to know is it possible to use UUID as type for my id field or not? Can I create some type of custom <code>MappingMongoConverter</code> for my entity? </p>