Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
Sessionsession=HibernateSessionFactory.getSession();Stringhql="fromStudent";Queryquer...
Session session=HibernateSessionFactory.getSession();
String hql="from Student";
Query query=session.createQuery(hql);
List<Student> list=query.list();
很好,很成功,就下面的时候,就发生错误了。。
…………………………………………………………………………………………
Session session=HibernateSessionFactory.getSession();
String hql="from Student";
Query query=session.createQuery(hql);
query.setFirstResult(0);
query.setMaxResults(3);
List<Student> list=query.list();
………………………………………………………………………………
Hibernate: select top ? student0_.sid as sid1_, student0_.sname as sname1_, student0_.sex as sex1_ from Tom.student student0_
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at demo.hibernate.seven.Test.findAll(Test.java:35)
at demo.hibernate.seven.Test.main(Test.java:14)
Caused by: java.sql.SQLException: ORA-00923: 未找到要求的 FROM 关键字
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1124)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 9 more
单独执行查询的没的问题,
就是执行分页查询的时候就报上面的错了。。 展开
String hql="from Student";
Query query=session.createQuery(hql);
List<Student> list=query.list();
很好,很成功,就下面的时候,就发生错误了。。
…………………………………………………………………………………………
Session session=HibernateSessionFactory.getSession();
String hql="from Student";
Query query=session.createQuery(hql);
query.setFirstResult(0);
query.setMaxResults(3);
List<Student> list=query.list();
………………………………………………………………………………
Hibernate: select top ? student0_.sid as sid1_, student0_.sname as sname1_, student0_.sex as sex1_ from Tom.student student0_
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2235)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2129)
at org.hibernate.loader.Loader.list(Loader.java:2124)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:401)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1149)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at demo.hibernate.seven.Test.findAll(Test.java:35)
at demo.hibernate.seven.Test.main(Test.java:14)
Caused by: java.sql.SQLException: ORA-00923: 未找到要求的 FROM 关键字
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:213)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:796)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1031)
at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:836)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1124)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1812)
at org.hibernate.loader.Loader.doQuery(Loader.java:697)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
at org.hibernate.loader.Loader.doList(Loader.java:2232)
... 9 more
单独执行查询的没的问题,
就是执行分页查询的时候就报上面的错了。。 展开
展开全部
我只是建议啊,hql语句的From Student的F大写试试
追问
整了N久,终于搞定:总结下
保证其它地方没问题的时候:看看hibernate.cfg.xml配置文件;首先:看看SQL方言是否配置正确,在进行分页查询,调用存储过程查询……都不能使用org.hibernate.dialect.HSQLDialect;其次:create -->要注释掉,不然可能导致数据丢失
。o(∩_∩)o 哈哈。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不知道你用的什么数据库 你看看 方言配对了吗
追问
单是方言的问题,可能会出现Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
,一般不会有后面半。。哈o(∩_∩)o 哈。。虽然没用上,但是占了边,。。打赏。。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询