title: JPA and PostgreSQL with GenerationType.IDENTITY
body: <p>I have a question about Postgres and GenerationType.Identity vs Sequence</p>
  
  <p>In this example...</p>
  
  <pre><code>@Id
  @SequenceGenerator(name="mytable_id_seq",
                     sequenceName="mytable_id_seq",
                     allocationSize=1)
  @GeneratedValue(strategy = GenerationType.SEQUENCE,
                  generator="mytable_id_seq")
  </code></pre>
  
  <p>I understand that I am specifying a Postgres sequence to use via annotations.</p>
  
  <p>However, I have an id column defined with the 'serial' type, I have read that I can simply use GenerationType.IDENTITY and it will automatically generate a db sequence and use it to auto increment.</p>
  
  <p>If that's the case, I don't see an advantage to using the SEQUENCE annotations unless you are using an integer for an id or have some specific reason to use another sequence you have created.  IDENTITY is alot less code and potentially makes it portable across databases.</p>
  
  <p>Is there something I'm missing? </p>
  
  <p>Thanks in advance for the feedback.</p>