求大神帮忙

来源:5-3 通过List返回查询结果

qq_果果_0

2016-12-19 10:30

按照老师代码写的出现错误了,百度半天也没弄明白,求解答。

org.hibernate.hql.ast.QuerySyntaxError: Unable to locate class [list] [select new list(name,tel) from com.imooc.model.Seller]

at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:63)

at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:196)

at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:130)

at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:83)

at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:414)

at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:821)

at org.hibernate.impl.SessionImpl.list(SessionImpl.java:779)

at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)

at com.imooc.model.CommodityTes.test1(CommodityTes.java:21)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Caused by:  Unable to locate class [list]

[cause=java.lang.ClassNotFoundException: list]

at org.hibernate.hql.ast.ConstructorNode.resolveConstructor(ConstructorNode.java:87)

at org.hibernate.hql.ast.ConstructorNode.prepare(ConstructorNode.java:58)

at org.hibernate.hql.ast.HqlSqlWalker.processConstructor(HqlSqlWalker.java:540)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExpr(HqlSqlBaseWalker.java:1518)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectExprList(HqlSqlBaseWalker.java:1396)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectClause(HqlSqlBaseWalker.java:996)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:379)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:200)

at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:150)

at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)

... 32 more


写回答 关注

3回答

  • linguanghua
    2016-12-19 20:49:08
    已采纳

    List里面类型又是List,里面的List没有说明类型吧

  • 慕粉3796571
    2017-06-17 14:46:22

    楼主是怎么解决的;问题出现在哪里?

  • qq_果果_0
    2016-12-20 14:47:27

    在hibernate 4.0版本中就是可以的,3.0就不行,感觉像是版本的问题,但是视频中用的3.0就可以


HQL数据查询基础

使用HQL从数据库中找到你要的数据,掌握了使用Hibernate

41151 学习 · 90 问题

查看课程

相似问题