title: Spring-Data JPARepository save method creates a duplicate Record
body: <p>I am using spring-data and hibernate for creating tables and inserting Data. From different threads i found that save method from JPARepository (From CRUDRepository) will only update the record if the record already exists. Below is one of the thread i found some information:</p>
  
  <p><a href="https://stackoverflow.com/a/40608937/10356053">https://stackoverflow.com/a/40608937/10356053</a></p>
  
  <p>I have an Entity which is duplicating the records (jpa is considering as a new insert even if the Object is same). I am not really sure whats happening or a Solution for this issue. Any suggestions are appreciated. Below is the Entity i have created:</p>
  
  <p>CustomerEntity.java:</p>
  
  <pre><code>@Getter
  @Setter
  @Table(name = "Customers")
  @Entity
  public class CustomersEntity extends BasicEntity {
        @Id
       @GeneratedValue(generator = "UUID")
       @GenericGenerator(name = "UUID", strategy = "org.hibernate.id.UUIDGenerator")
       @Column(name = "CustomerId", updatable = false, nullable = false)
       private UUID customerid;
  
       //and some other fields
  }
  </code></pre>
  
  <p>BasicEntity.java:</p>
  
  <pre><code>@Getter
  @Setter
  public class BasicEntity implements serializable {
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "created_at", updatable = false)
      @CreatedDate
      private Date createdAt;
  
      @Temporal(TemporalType.TIMESTAMP)
      @Column(name = "updated_at")
      @LastModifiedDate
      private Date updatedAt;
  }
  </code></pre>
  
  <p>Repository.java</p>
  
  <pre><code>@Repository
  public interface Repositorty extends JpaRepository&lt;CustomersEntity, UUID&gt; {
  
  
  }
  </code></pre>
  
  <p>When we are trying to save the above entites:</p>
  
  <pre><code>repository.save(customerEntity)
  </code></pre>
  
  <p>will persist as a new record in the database. Any suggestions are helpful. I am thinking is this because of the createdTime and updatedTime from the parent class? If yes, how do we avoid this? TIA.</p>