自由飛翔

          我在仰望,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)  編輯  收藏 所屬分類: 異常積累

          主站蜘蛛池模板: 平阳县| 图木舒克市| 惠水县| 黄大仙区| 嵊泗县| 南阳市| 甘泉县| 江西省| 海口市| 武清区| 克什克腾旗| 富宁县| 修文县| 安乡县| 石阡县| 三亚市| 洪湖市| 惠安县| 土默特左旗| 霸州市| 高陵县| 项城市| 论坛| 商丘市| 闻喜县| 云浮市| 买车| 德安县| 当雄县| 承德市| 湄潭县| 藁城市| 连城县| 花垣县| 隆德县| 安溪县| 商丘市| 澄城县| 秦安县| 买车| 北京市|