当前位置: 代码迷 >> Oracle管理 >> 郁闷了好多天的有关问题了,帮忙看看!
  详细解决方案

郁闷了好多天的有关问题了,帮忙看看!

热度:78   发布时间:2016-04-24 05:56:38.0
郁闷了好多天的问题了,帮忙看看!!
我连接的是oracle数据库,然后用hibernate映射,但是我写了一条查询语句,然后报找不到表或视图的错误。 
我写的函数如下:public List findSmeoeDMenu() 
  { 
  List list=null; 
  log.debug("find SmeoeDMenu instance"); 
  try 
  {  
  Transaction tx = getSession().beginTransaction();  
  Query q = getSession().createQuery("from SmeoeDMenu where menuLevel='1' and parentId='0' and enableFlag='Y' order by showOrder asc "); 
  list = q.list();  
  tx.commit(); 
  log.debug("find successful"); 
  return list;  
  } 
  catch(RuntimeException re) 
  { 
  log.error("find failed",re); 
  throw re; 
  } 
  }主要看sql语句就可以了,报得错误如下: 
log4j:WARN No appenders could be found for logger (com.bestoe.smeoe.hibernate.dao.SmeoeDMenuDAO). 
log4j:WARN Please initialize the log4j system properly. 
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query 
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67) 
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) 
at org.hibernate.loader.Loader.doList(Loader.java:2148) 
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029) 
at org.hibernate.loader.Loader.list(Loader.java:2024) 
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375) 
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308) 
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153) 
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106) 
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79) 
at com.bestoe.smeoe.hibernate.dao.SmeoeDMenuDAO.findSmeoeDMenu(SmeoeDMenuDAO.java:35) 
at com.bestoe.smeoe.hibernate.dao.SmeoeDMenuDAO.main(SmeoeDMenuDAO.java:319) 
Caused by: java.sql.SQLException: ORA-00942: 表或视图不存在 

at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) 
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289) 
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582) 
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1986) 
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:880) 
at oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2516) 
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2850) 
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:609) 
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:537) 
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139) 
at org.hibernate.loader.Loader.getResultSet(Loader.java:1669) 
at org.hibernate.loader.Loader.doQuery(Loader.java:662) 
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) 
at org.hibernate.loader.Loader.doList(Loader.java:2145) 
... 9 more 
请求帮忙!!!

------解决方案--------------------
看看你登陆的用户模式下是否有这个表,确保使用这个用户登陆
  相关解决方案