title: H2: Sequence not found Exception, but exists in my schema
body: <p>I am using Spring Boot, Hibernate/JPA and H2 to develop some entities. </p>
  
  <p>If I create the table/sequence in the H2 public schema then all is OK and I am able to read/insert into the database from my application. </p>
  
  <p>However, if I create the table/sequence in a schema I have created I am unable to insert because the sequence cannot be found. I can see it in the H2 database and it appears to be in the right schema, I can manually select from it but when trying to do an insert in my code I get:</p>
  
  <pre><code>Caused by: org.h2.jdbc.JdbcSQLException: Sequence "VENUE_SQ" not found; SQL statement:
  call next value for VENUE_SQ [90036-191]
      at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.191.jar:1.4.191]
      at org.h2.message.DbException.get(DbException.java:179) ~[h2-1.4.191.jar:1.4.191]
      at org.h2.message.DbException.get(DbException.java:155) ~[h2-1.4.191.jar:1.4.191]
      at org.h2.command.Parser.readSequence(Parser.java:5399) ~[h2-1.4.191.jar:1.4.191]
      at org.h2.command.Parser.readTerm(Parser.java:2806) ~[h2-1.4.191.jar:1.4.191]
  etc...
  </code></pre>
  
  <p>Some DDL:</p>
  
  <pre><code>create schema MY_SCHEMA AUTHORIZATION MY_SCHEMA_OWNER;
  set schema MY_SCHEMA;
  
  create sequence VENUE_SQ;
  
  CREATE TABLE VENUE (
     ID number not null,
     NAME varchar2(255) not null, etc...
  </code></pre>
  
  <p>Some DML:</p>
  
  <pre><code>INSERT INTO VENUE (ID, NAME, etc...
  </code></pre>
  
  <p>Some JPA</p>
  
  <pre><code>@Entity
  @Table(name = "VENUE", schema = "MY_SCHEMA")
  @SequenceGenerator(name = "ID",  sequenceName = "VENUE_SQ",
  allocationSize = 1, schema = "MY_SCHEMA")
  public class Venue {
  
      @Id
      @GeneratedValue(generator = "ID", strategy = GenerationType.SEQUENCE)
      @Column(name = "ID", nullable = false)
      private Long id;
  
      @Column(name = "NAME")
      private String name;
  
  etc...
  </code></pre>
  
  <p>Hibernate 4.3.11</p>
  
  <p>H2 1.4</p>
  
  <p>Spring boot 1.3.3.RELEASE</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I've managed to get this working by prefixing the sequence name with the schema in the @SequenceGenerator annotation. I don't believe this should be necessary as I have given the schema in the parameters for that annotation!</p>
  
  <pre><code>@SequenceGenerator(name = "ID",  sequenceName = "MY_SCHEMA.VENUE_SQ",
  allocationSize = 1, schema = "MY_SCHEMA")
  </code></pre>
  
  <p>So, I'm not done with this problem yet as I would like to understand what the issue is.</p>
  
  <p><strong>UPDATE 2</strong></p>
  
  <p>See my answer below, this is related to a Hibernate bug in our version.</p>