自由飛翔

          我在仰望,java之上

          統計

          留言簿(2)

          我關注的blog

          閱讀排行榜

          評論排行榜

          異常積累:org.hibernate.hql.ast.QuerySyntaxError: User is not mapped. [from User where username=?]

          org.hibernate.hql.ast.QuerySyntaxError: User is not mapped. [from User where username=?]
          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:427)
          at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:884)
          at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)
          at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
          at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:603)
          at com.demo.hibernate.dao.UserDAOImpl.select(UserDAOImpl.java:19)
          at com.demo.hibernate.service.UserServiceImpl.login(UserServiceImpl.java:21)
          at com.demo.hibernate.test.UserServiceTest.testLogin(UserServiceTest.java:25)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
          at java.lang.reflect.Method.invoke(Unknown Source)
          at junit.framework.TestCase.runTest(TestCase.java:154)
          at junit.framework.TestCase.runBare(TestCase.java:127)
          at junit.framework.TestResult$1.protect(TestResult.java:106)
          at junit.framework.TestResult.runProtected(TestResult.java:124)
          at junit.framework.TestResult.run(TestResult.java:109)
          at junit.framework.TestCase.run(TestCase.java:118)
          at junit.framework.TestSuite.runTest(TestSuite.java:208)
          at junit.framework.TestSuite.run(TestSuite.java:203)
          at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
          at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
          at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
          Caused by:  User is not mapped.
          at org.hibernate.hql.ast.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:85)
          at org.hibernate.hql.ast.FromElementFactory.addFromElement(FromElementFactory.java:77)
          at org.hibernate.hql.ast.FromClause.addFromElement(FromClause.java:67)
          at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:217)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:2830)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2719)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:513)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:371)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:201)
          at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:151)
          at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:189)
          ... 28 more
          原因:

          hibernate.cfg.xml映射.<mapping resource=""/>的配置

          類似原因還可能有:
           
          hql是寫的是table名,不是POJO對象


          Gavin

          posted on 2012-01-19 11:02 GavinMiao 閱讀(6149) 評論(0)  編輯  收藏 所屬分類: 異常積累

          主站蜘蛛池模板: 岳阳市| 三亚市| 长顺县| 新干县| 长丰县| 阿城市| 宣威市| 东明县| 阿荣旗| 错那县| 辛集市| 嘉兴市| 常宁市| 罗田县| 长顺县| 禄丰县| 贞丰县| 汉寿县| 金门县| 苍南县| 灵石县| 班玛县| 镇原县| 黄陵县| 金乡县| 广饶县| 北辰区| 渝中区| 龙井市| 蓝田县| 梨树县| 博白县| 维西| 华安县| 土默特左旗| 象山县| 左贡县| 阳原县| 滁州市| 罗山县| 渝中区|