title: Merging the same entity twice causes INSERT-Primary Key violation
body: <p>I have a quite simple JAP-Entity without any links to other classes:</p>
  
  <pre><code>@Entity
  @IdClass(TimestampNameAndGroupIdentity.class)
  public class TechFitMainClassHistory extends JPABase {
  
      @Id
      @Basic
      protected Date timestamp;
  
      @Id
      @Basic
      protected String type_name;
  
      @Id
      @Basic
      protected String group_name;
  
      @Basic
      protected int count;
  
      ...
  </code></pre>
  
  <p>with IdClass:</p>
  
  <pre><code>public class TimestampNameAndGroupIdentity implements Serializable {
      private static final long serialVersionUID = 1L;
  
      public Date timestamp;
      public String type_name;
      public String group_name;
  
      ...
  </code></pre>
  
  <p>When in a test I try to merge it twice:</p>
  
  <pre><code>        em.merge(new TechFitMainClassHistory(date, "com.test.Main", "java", 2));
          em.merge(new TechFitMainClassHistory(date, "com.test.Main", "java", 2));
  </code></pre>
  
  <p>I get the following error</p>
  
  <pre><code>Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: Violation of PRIMARY KEY constraint 'PK__TechFitM__D91CE761E4A3725C'. Cannot insert duplicate key in object 'dbo.TechFitMainClassHistory'. The duplicate key value is (PROCESS_TYPE_MAIN, 2015-09-03 00:00:00.0000000, com.ruxit.Main). {prepstmnt 261650860 INSERT INTO TechFitMainClassHistory (group_name, timestamp, type_name, count) VALUES (?, ?, ?, ?)} [code=2627, state=23000]
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:219)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:207)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$1200(LoggingConnectionDecorator.java:59)
      at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeBatch(LoggingConnectionDecorator.java:1215)
      at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeBatch(DelegatingPreparedStatement.java:250)
      at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeBatch(JDBCStoreManager.java:1810)
      at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.executeBatch(BatchingPreparedStatementManagerImpl.java:364)
      at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushBatch(BatchingPreparedStatementManagerImpl.java:189)
      ... 39 more
  </code></pre>
  
  <p>There are two cases where the error does not appear:
  * If I commit between the calls
  * If the object already exists before the calls</p>
  
  <p>This is just the reduced test-case, the actual application does similar things and I would expect things to work based on the description of the merge() method.</p>
  
  <p>So why do I get this error? I would expect merge to work multiple times or this is a bug/limitation in OpenJPA?</p>