title: Spring data mongodb. Generating id's error
body: <p>I have made an experiment... one common entity for two Spring data's repositories:
  - JPA
  - MongoDB</p>
  
  <p>first of all I' using following libraries versions:</p>
  
  <p>spring-data-jpa : 1.7.0.RELEASE
  spring-data-mongodb : 1.6.0.RELEASE</p>
  
  <p>I have an Entity:</p>
  
  <pre><code>@Entity
  @Table(name = "ACCOUNTS")
  public class Account {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "ACCOUNT_ID")
      private Long id;
  
      @Column(name = "ACCOUNT_NUMBER")
      private String number;
  
      public Account() {
      }
  
      public Account(String number) {
          this.number = number;
      }
  
      public Long getId() {
          return id;
      }
  
      public void setId(Long id) {
          this.id = id;
      }
  
      public String getNumber() {
          return number;
      }
  
      public void setNumber(String number) {
          this.number = number;
      }
  }
  </code></pre>
  
  <p>JPA Repository has following look:</p>
  
  <pre><code>public interface Repository extends CrudRepository&lt;Account, Long&gt; {
      public Account findByNumber(String number);
  }
  </code></pre>
  
  <p>MongoDB repository has following look:</p>
  
  <p>package ua.home.springdata.investigation.repository.mongo;</p>
  
  <pre><code>public interface Repository extends CrudRepository&lt;Account, Long&gt; {
  }
  </code></pre>
  
  <p>So... JPA works :) Nothing special :)
  But MongoDB test is not passed :(
  I'm getting an error:</p>
  
  <pre>
  org.springframework.dao.InvalidDataAccessApiUsageException: Cannot autogenerate id of type java.lang.Long for entity of type ua.home.springdata.investigation.entity.Account!
      at org.springframework.data.mongodb.core.MongoTemplate.assertUpdateableIdIfNotSet(MongoTemplate.java:1149)
      at org.springframework.data.mongodb.core.MongoTemplate.doSave(MongoTemplate.java:878)
      at org.springframework.data.mongodb.core.MongoTemplate.save(MongoTemplate.java:833)
      at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save(SimpleMongoRepository.java:73)
      at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save(SimpleMongoRepository.java:88)
      at org.springframework.data.mongodb.repository.support.SimpleMongoRepository.save(SimpleMongoRepository.java:45)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:442)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:427)
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:381)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
      at com.sun.proxy.$Proxy26.save(Unknown Source)
  </pre>
  
  <p>I think it's a very common case. Why is not Spring data able to generate entity id as Long? It's so weird.</p>