title: Using @GeneratedValue(strategy=GenerationType.IDENTITY) in populated database causes PK constraint error
body: <p>I'm trying to add <code>FeedbackItem</code> items to my database. The general idea is that an existing object of type <code>Group</code> can receive multiple <code>FeedbackItem</code> objects. Afterwards I update the object:</p>
  
  <pre><code>groupDAO.startTransaction();
  groupDAO.update(selectedGroup);
  groupDAO.commitTransaction();
  
  //in groupDAO
  public T update(T entity){
     return em.merge(entity);
  }
  </code></pre>
  
  <p>I'm not suring whether it is JPA causing the issue or not, but the following error will appear:</p>
  
  <blockquote>
    <p>Internal Exception: java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'SQL170430012202680' defined on 'FEEDBACKITEM'.</p>
  </blockquote>
  
  <p>After some more debugging I found the following entries:</p>
  
  <blockquote>
    <p>[EL Fine]: sql: 2017-04-30 01:22:14.977-- #### VALUES (?, ?) bind =>
    [sampleText, 2]</p>
    
    <p>[EL Fine]: sql: 2017-04-30
    01:22:14.997--ClientSession(889348271)--Thread(Thread[JavaFX
    Application Thread,5,main])--VALUES(1)</p>
  </blockquote>
  
  <p>Does <code>VALUES(1)</code> mean that it's trying to insert the object under the ID 1? It's the only lead I currently have. My database is populated with 10 entries, having an ID ranging from 1 to 10.</p>
  
  <p>Below is the class I'm trying to persist to the database:</p>
  
  <pre><code>@Entity
  public class FeedbackItem implements Serializable{
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int feedbackId;
  
      private String feedback;
  
      @ManyToOne(cascade = CascadeType.PERSIST)
      private User ownerFeedback;
  
      protected FeedbackItem(){
  
      }
  }
  </code></pre>
  
  <p>I tested my code without <code>@GeneratedValue(strategy=GenerationType.IDENTITY)</code> and assigned ID's manually. This works without any issues.</p>
  
  <p><strong>EDIT:</strong> below is the <code>Group</code> entity:</p>
  
  <pre><code>@Entity
  public class Group implements IReadOnlyGroup {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private int groupId;
      private String name;
  
      @OneToMany(mappedBy = "group")
      private List&lt;Action&gt; actions;
  
      @OneToMany(cascade = CascadeType.PERSIST)
      private List&lt;Proposal&gt; proposals;
  
      @OneToMany(mappedBy = "group")
      private List&lt;Motivation&gt; motivations;
  
      @OneToOne(mappedBy = "group")
      private GroupState currentState;
  
      public Groep() {
      }
  }
  </code></pre>
  
  <p>The <code>Group</code> object contains the <code>FeedbackItem</code> objects indirectely. Each <code>Proposal</code> stores one <code>FeedbackItem</code></p>
  
  <pre><code>Entity
  public class Proposal {
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Long id;
  
      @Temporal(TemporalType.TIMESTAMP)
      private Date date = null;
  
      @ManyToMany
      private List&lt;Action&gt; actions;
  
      @OneToOne
      private FeedbackItem feedbackitem;
  
      boolean approved;
  
      protected Proposal() {
  
      }
  
      public Proposal ( List&lt;Action&gt; actions, String feedback, boolean approved, User owner){
          this.date = new Date();
          this.actions = actions;
          this.approved = approved;
          this.feedbackitem = new FeedBackItem(feedback, owner);
      }
  }
  </code></pre>