title: JPA/Spring-boot Duplicate entry for key 'PRIMARY'
body: <p>I am using JPA for mysql operations, but the few times I am getting error while performing mysql save operations through JPA.
  Error while performing save operation => </p>
  
  <blockquote>
    <p>Could not open JPA EntityManager for transaction; Duplicate entry for key 'PRIMARY'</p>
  </blockquote>
  
  <p><strong>Table Model Class:</strong></p>
  
  <pre><code>@Entity
  @Table(name="table_x")
  @JsonIgnoreProperties(ignoreUnknown = true)
  @JsonInclude(JsonInclude.Include.NON_NULL)
  @Data
  @TypeDefs({
          @TypeDef(name = "json", typeClass = JsonStringType.class),
          @TypeDef(name = "jsonb", typeClass = JsonBinaryType.class),
  })
  public class tableX implements Serializable {
  
      @Id
      @Column(name="product_id")
      private Long productId;
  
      @Column(name="parent_id")
      private Long parentId;
  
      // other fields
  }
  </code></pre>
  
  <p><strong>Mysql Schema:</strong></p>
  
  <pre><code> CREATE TABLE `table_x` (
    `product_id` int(12) unsigned NOT NULL,
    `parent_id` int(12) unsigned DEFAULT NULL,
    // other fields
    PRIMARY KEY (`product_id`)
  )
  </code></pre>
  
  <p><strong>Repository Class:</strong></p>
  
  <pre><code>@Repository
  public interface TableXRepository extends CrudRepository&lt;tableX,Long&gt; {
  }
  </code></pre>
  
  <p><strong>Mysql Operation Class:</strong></p>
  
  <pre><code>@Component
  @Transactional
  public class tableXoperationImpl implements ItableXoperation {
  
      @Autowired
      private TableXRepository tableXRepository;
  
      public void save(tableX data) {
          tableXRepository.save(data);
      }
  }
  </code></pre>
  
  <p>is anything, I am missing here, any help will be appreciated.</p>