title: hibernate.exception.SQLGrammarException: could not extract ResultSet: ORA-00942: table or view does not exist
body: <p>I am working on a hibernate application and trying to extract data from table (oracle sql). But the query result is throwing </p>
  
  <p>hibernate.exception.SQLGrammarException: could not extract ResultSet: and root cause is java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist.</p>
  
  <p>The table is still in the database.</p>
  
  <p>Here is the full stack trace of the exception</p>
  
  <pre><code>Jan 31, 2017 3:36:46 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [/Shopping] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: 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:440)
      at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
      at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
      at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
      at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
      at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
      at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
      at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
      at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
      at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
      at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
      at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
      at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
      at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
      at org.apache.tomcat.dbcp.dbcp2.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:82)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70)
      at org.hibernate.loader.Loader.getResultSet(Loader.java:2123)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1911)
      at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1887)
      at org.hibernate.loader.Loader.doQuery(Loader.java:932)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:349)
      at org.hibernate.loader.Loader.doList(Loader.java:2615)
      at org.hibernate.loader.Loader.doList(Loader.java:2598)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2430)
      at org.hibernate.loader.Loader.list(Loader.java:2425)
      at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:502)
      at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
      at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
      at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1473)
      at org.hibernate.query.internal.AbstractProducedQuery.doList(AbstractProducedQuery.java:1426)
      at org.hibernate.query.internal.AbstractProducedQuery.list(AbstractProducedQuery.java:1398)
      at com.shopping.dao.addItem.preload.Item_Category_DaoImpl.GetItemCategory(Item_Category_DaoImpl.java:21)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
      at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:282)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
      at com.sun.proxy.$Proxy23.GetItemCategory(Unknown Source)
      at com.shopping.services.addItem.preload.Item_Category_ServiceImpl.GetItemCategory(Item_Category_ServiceImpl.java:20)
      at com.shopping.controller.addItem.preload.LoadBrandCategoryItem.Action(LoadBrandCategoryItem.java:25)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:497)
      at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:220)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1419)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:44)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Thread.java:745)
  
  Hibernate: select categorylo0_.cat_id as cat_id1_0_, categorylo0_.category_name as category_name2_0_ from test.itemcategory categorylo0_
  Jan 31, 2017 3:36:48 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  WARN: SQL Error: 942, SQLState: 42000
  Jan 31, 2017 3:36:48 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
  ERROR: ORA-00942: table or view does not exist
  </code></pre>
  
  <p>This is my entity class</p>
  
  <pre><code>@Entity
  @Table(name="itemcategory")
  public class CategoryLoader {
  
      @Id
      private String Cat_Id;
  
      @Column(name="category_name")
      private String Category_Name;
  
      public String getCat_Id() {
          return Cat_Id;
      }
  
      public void setCat_Id(String cat_Id) {
          Cat_Id = cat_Id;
      }
  
      public String getCategory_Name() {
          return Category_Name;
      }
  
      public void setCategory_Name(String category_Name) {
          Category_Name = category_Name;
      }
  }
  </code></pre>
  
  <p>This is the code for dao implementation</p>
  
  <pre><code>session.getCurrentSession().createQuery("from CategoryLoader").list();
  </code></pre>
  
  <p>THis is the configuration </p>
  
  <pre><code>&lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate5.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.Oracle10gDialect&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.enable_lazy_load_no_trans"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.default_schema"&gt;test&lt;/prop&gt;
              &lt;prop key="format_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="use_sql_comments"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
      &lt;property name="packagesToScan"&gt;
          &lt;list&gt;
              &lt;value&gt;com.entities.addItem.preload&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>