title: Why is GenerationType.AUTO not using a serial on PostgreSQL?
body: <p>I have an application using JPA (with eclipselink). The application was developed with a Derby database in the background. The tables were generated by JPA itself. This is a simple example of one of the entities:</p>
  
  <pre><code>public class MyEntity implements Serializable {
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
  
    @Column(nullable=false)
    private String someString;
  }
  </code></pre>
  
  <p>JPA then created another table <code>SEQUENCE</code> to generate the ID.
  We now want to switch to PostgreSQL and instead of a table <code>SEQUENCE</code> we want to use real sequences in PostgreSQL. This is the DDL we used to create the table:</p>
  
  <pre><code>CREATE TABLE MYENTITY (
    ID serial PRIMARY KEY NOT NULL,
    SOMESTRING varchar(255) NOT NULL
  )
  </code></pre>
  
  <p>But still JPA wants to use the <code>SEQUENCE</code> table (that doesn't exist):</p>
  
  <pre><code>Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.          persistence.exceptions.DatabaseException
  Internal Exception: org.postgresql.util.PSQLException: ERROR: relation "sequence" does not exist
      Position: 8
  Error Code: 0
  Call: UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ?
      bind =&gt; [2 parameters bound]
  Query: DataModifyQuery(name="SEQUENCE" sql="UPDATE SEQUENCE SET SEQ_COUNT = SEQ_COUNT + ? WHERE SEQ_NAME = ? ")
  </code></pre>
  
  <p>I know that I could change the generation strategy to <code>SEQUENCE</code>, but I want to have the code portable. <code>GenerationType.SEQUENCE</code> shouldn't work with databases that don't support sequences. And I expect that <code>AUTO</code> would use a sequence on PostgreSQL. Why doesn't it? Do I have to do something else?</p>
  
  <p>As a note, it seems that JPA used a sequence automatically in the question <a href="https://stackoverflow.com/questions/13107502/generatedvalue-in-postgres">Generated Value in Postgres</a>.</p>