title: Oracle Table got dropped by Hibernate; flashed back to DB from recycle bin. Getting error "SQL Error: 942, SQLState: 42000"
body: <p>Working on Spring Data + JPA + Hibernate + Maven project. </p>
  
  <p>Sequence of events:</p>
  
  <ol>
  <li><p>I had a working code using the above which used to query the <code>Favorites</code> Table using <code>JPARespository</code>. I added a line <code>props.put("hibernate.hbm2ddl.auto");</code> to the JPA Properties and the table Favorites gets dropped. Sheer panic! </p>
  
  <p>properties.put("hibernate.hbm2ddl.auto",environment.getRequiredProperty("hibernate.hbm2ddl.auto"));</p></li>
  <li><p>I comment the code which caused the trouble. I request the DBA to recreate the table and she says it was in the recycle bin and she "flashed" it back. </p>
  
  <p><code>private Map jpaProperties() {
          Map&lt;String,Object&gt; properties = new HashMap&lt;String,Object&gt;();
          properties.put("hibernate.dialect",
                  environment.getRequiredProperty("hibernate.dialect"));
  //      properties.put("hibernate.hbm2ddl.auto",
  //              environment.getRequiredProperty("hibernate.hbm2ddl.auto"));
          properties.put("hibernate.show_sql",
                  environment.getRequiredProperty("hibernate.show_sql"));
          properties.put("hibernate.format_sql",
                  environment.getRequiredProperty("hibernate.format_sql"));
          return properties;
      }</code></p></li>
  </ol>
  
  <p>Database config method:</p>
  
  <pre><code>`@Primary
   @Bean(name = "dataSource")
   public DataSource dataSource() {
  DriverManagerDataSource dataSource = new DriverManagerDataSource();
  dataSource.setDriverClassName(environment
              .getRequiredProperty("rg.jdbc.driverClassName"));
  dataSource.setUrl(environment.getRequiredProperty("rg.jdbc.url"));
  dataSource.setUsername(environment
              .getRequiredProperty("rg.jdbc.username"));
  dataSource.setPassword(environment
              .getRequiredProperty("rg.jdbc.password"));
  return dataSource;
  }`
  </code></pre>
  
  <ol start="3">
  <li>I can see the Table in SQL Developer using the same user credentials being used in the code. However, if I query the DB using <code>JPARepository</code> extended class using the <code>findAll()</code>.</li>
  </ol>
  
  <p>I am getting the following error. I can see the Table in the DB, but not via the Java code. </p>
  
  <p>Can somebody help me understand what does the above property do and why I can't see the table via the code, but can see it in SQL Developer? Also, how can I fix this?</p>
  
  <pre><code>Hibernate: 
  select
      favorite0_.FAVORITE_ID as FAVORITE_ID1_1_,
      favorite0_.category as category2_1_,
      favorite0_.created as created3_1_,
      favorite0_.CREATED_BY as CREATED_BY4_1_,
      favorite0_.description as description5_1_,
      favorite0_.name as name6_1_,
      favorite0_.OBJECT_TYPE_ID as OBJECT_TYPE_ID7_1_ 
  from
      FAVORITES favorite0_
  2017-09-22 02:21:20 [http-bio-8080-exec-2] WARN  o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 942, SQLState: 42000
  2017-09-22 02:21:20 [http-bio-8080-exec-2] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - ORA-00942: table or view does not exist
  
  Sep 22, 2017 1:24:11 AM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/RG-NG] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
  java.sql.SQLSyntaxErrorException: ORA-00942: table or view 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:1017)
  at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:655)
  at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:249)
  at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:566)
  at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:215)
  at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:58)
  at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:776)
  at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:897)
  at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1034)
  at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3820)
  at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3867)
  at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1502)
  at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
  at org.hibernate.loader.Loader.getResultSet(Loader.java:2117)
  at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1900)
  </code></pre>