title: JPA (Hibernate): "ORA-02289 Sequence does not exist", but it does
body: <p>I'm working with JPA entities. </p>
  
  <p>I created a new one like this:</p>
  
  <pre><code>@Entity
  public class Entity {
      @Id
      @GeneratedValue(generator = "Entity_Sequence", strategy = GenerationType.SEQUENCE)
      @SequenceGenerator(name = "Entity_Sequence", sequenceName = "Entity_Seq")
      private Long id;
  
      // ... other fields
  }
  </code></pre>
  
  <p>Generated SQL I used to create DB Objects:</p>
  
  <pre><code>CREATE SEQUENCE ENTITY_SEQ START WITH 1 INCREMENT BY 50;
  
  CREATE TABLE ENTITY (
    ID     NUMBER(19, 0) NOT NULL,
    -- ... other fields
    PRIMARY KEY (ID)
  );
  </code></pre>
  
  <p>Now, I am able to query the nextval of the sequence from SQL Developer and from IntelliJ. But when I try to persist an entity from code, Hibernate throws the following exception:</p>
  
  <pre><code>15:21:11,022 INFO  [stdout] (EJB default - 2) Hibernate: select ENTITY_SEQ.nextval from dual
  15:21:11,037 WARN  [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (EJB default - 2) SQL Error: 2289, SQLState: 42000
  15:21:11,037 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (EJB default - 2) ORA-02289: Sequence ist nicht vorhanden.
  </code></pre>
  
  <p>("Sequence ist nicht vorhanden" translates to "Sequence does not exist".)</p>
  
  <p>Why is Hibernate not able to find the sequence while I am?</p>
  
  <p><strong>EDIT 1 (12-01)</strong>:<br>
  I tried the suggested <a href="https://stackoverflow.com/a/47595619/9039441">answer from Olivier</a>, but the error is still the same. </p>
  
  <p><strong>EDIT 2 (12-01)</strong>:<br>
  Since Olivier deleted his answer, he suggested I move the <code>@SequenceGenerator</code> annotation to the class.</p>