title: Spring data JPA does not allow an Entity to be peristed if the primary key is not null
body: <p>I have a Subscriber Entity which uses a <strong>user supplied email address as the primary key</strong> rather than an auto-generated value. This means that when the save method of the JpaRepository is called, the primary key value is <strong>not null</strong>.</p>
  
  <p>Spring data JPA <a href="http://docs.spring.io/spring-data/jpa/docs/1.4.1.RELEASE/reference/html/jpa.repositories.html" rel="nofollow noreferrer">documentation</a> <strong>section 2.2.1 table 2.2</strong> says the following:</p>
  
  <blockquote>
    <p>By default Spring Data JPA inspects the Id-Property of the given
    Entity. If the Id-Property is null, then the entity will be assumed as
    new, otherwise as not new.</p>
  </blockquote>
  
  <p>This behaviour prevents a new Subscriber entity from being persisted to the database.</p>