title: ORA-02289: sequence does not exist, however sequence is aleady exist in database
body: <p>I have been working on a java spring project, in which I have created a class whose sole purpose is to record the request body for every service have been called in the database.</p>
  <p>The table contains a primary key named as transaction_id and other fields which is required to records the request. The model of the tables in Java looks like:</p>
  <pre><code>@Entity
  @Table(name=&quot;ForntEndLogHistory&quot;)
  public class FrontEndLog {
      
      @Id
      @Column(name = &quot;TRANSACTION_ID&quot;)
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;id_generator&quot;)
      @SequenceGenerator(name=&quot;id_generator&quot;, sequenceName = &quot;id_seq2&quot;, allocationSize=1)
      private Long transactionId;
      private String request;
  }
  </code></pre>
  <p>In the database, I have created one sequence named as <strong>id_seq2</strong> whereas <strong>id_seq1</strong> already exists:</p>
  <p><strong>Newly created id_seq2:</strong></p>
  <pre><code>CREATE SEQUENCE  &quot;id_seq2&quot;  MINVALUE 0 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;
  commit;
  </code></pre>
  <p><strong>Already exists id_seq1 dll:</strong></p>
  <pre><code>CREATE SEQUENCE  &quot;id_seq1&quot;  MINVALUE 0 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 3467 NOCACHE  NOORDER  NOCYCLE ;
  </code></pre>
  <p><strong>case 1:</strong></p>
  <p>whenever I trigger any services from the postman with below sequence generator with sequence name id_seq2 I get the error &quot;sequence does not exist&quot;. However, the sequence is already there in DB.</p>
  <pre><code>@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;id_generator&quot;)
      @SequenceGenerator(name=&quot;id_generator&quot;, sequenceName = &quot;id_seq2&quot;, allocationSize=1)
      private Long transactionId;
  </code></pre>
  <p>The project war file is successfully deployed on the server. After that whenever the service is trigger from the postman following error is occurred:</p>
  <pre><code>org.hibernate.exception.SQLGrammarException: could not extract ResultSet
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:124)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:109)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:88)
      at org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:122)
      at org.hibernate.id.SequenceHiLoGenerator.generate(SequenceHiLoGenerator.java:73)
      at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:117)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:206)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:191)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
      at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
      at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:654)
      at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:646)
      at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:642)
      at com.etisalat.mwallet.data.BaseDAO.save(BaseDAO.java:49)
      at com.etisalat.mwallet.service.impl.LoggerService.logFrontEnd(LoggerService.java:59)
      at com.etisalat.mwallet.service.impl.LoggerService.logFrontEndSuccess(LoggerService.java:29)
      at com.etisalat.mwallet.rest.config.ResponseFilter.doFilter(ResponseFilter.java:180)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3436)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3402)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
      at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2285)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2201)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1572)
      at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:255)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
  Caused by: java.sql.SQLSyntaxErrorException: ORA-02289: sequence does not exist
  
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:225)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:53)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:774)
      at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:925)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1111)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:4798)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:4845)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1501)
      at weblogic.jdbc.wrapper.PreparedStatement.executeQuery(PreparedStatement.java:141)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
  </code></pre>
  <p><strong>case 2:</strong></p>
  <p>Afterward for testing purpose, I have change the sequence name from id_seq2 to id_seq1 and redeployed the code on server and surprisely I am able to trigger the service sucessfully.</p>
  <pre><code>@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = &quot;id_generator&quot;)
      @SequenceGenerator(name=&quot;id_generator&quot;, sequenceName = &quot;id_seq1&quot;, allocationSize=1)
      private Long transactionId;
  </code></pre>
  <p>Output:</p>
  <blockquote>
  <p>{</p>
  <p>&quot;responseCode&quot;: &quot;0&quot;</p>
  <p>}</p>
  </blockquote>
  <p>I have no idea where I made a mistake as in my point of view, there is something which I have missed in sequence generator.</p>