title: Incompatible sequence names between Liquibase and Hibernate JPA for PostgreSQL and H2
body: <p>I have an app running with standard Hibernate JPA and Liquibase for generating the db. I use H2 for testing and PostgreSQL when running.</p>
  
  <p>My problem is I can't seem to get this setup to work nicely for primary keys with sequence generation.</p>
  
  <p>When I have an entity id like this:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long id;
  </code></pre>
  
  <p>and use liquibase to create the database, like this:</p>
  
  <pre><code>&lt;column name="id" type="BIGINT" autoIncrement="true" incrementBy="1"&gt;
      &lt;constraints nullable="false" primaryKey="true" /&gt;
  &lt;/column&gt;
  </code></pre>
  
  <p>it works fine in H2, but for PostgreSQL Hibernate complains that it is:</p>
  
  <pre><code>"Missing sequence or table: hibernate_sequence"
  </code></pre>
  
  <p>I can fix this for PostgreSQL by changing the JPA @GeneratedValue to something like:</p>
  
  <pre><code>@Id
  @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "text_id_seq")
  @SequenceGenerator(name = "text_id_seq", sequenceName = "text_id_seq", allocationSize = 1)
  private Long id;
  </code></pre>
  
  <p>But now the H2 sequence won't match what Hibernate expects.</p>
  
  <p>There doesn't seem to be any easy way to make sure Liquibase the sequence with a specific name. What can I do to get this setup to work?</p>
  
  <p>I'm looks like I'm currently running </p>
  
  <ul>
  <li>liquibase.version 2.0.4</li>
  <li>hibernate 4.1.7</li>
  <li>postgres driver 9.1-901.jdbc3</li>
  <li>postgres 9.2.1 (at least locally)</li>
  <li>h2 1.3.168</li>
  </ul>