org.hibernate.hql.ast.QuerySyntaxException is not mapped

我用Hibernate实现一个教师的登陆过程,当我在JSP的登陆页面输入姓名和密码,点登陆后,显示登陆失败页,在服务器里显示如下的错误信息:
    org.hibernate.hql.ast.QuerySyntaxException: teachers is not mapped. [from teache
rs tea where tea.name=:teaName and tea.password=:teaPassword]
HQL错了
因为Hibernate是对类查询的
在hql="from teachers tea where tea.name=:teaName and tea.password=:teaPassword";中,
teachers是数据库中的表,而teachers对应的类是Teachers.java,现在只需要将teachers改为Teachers就可以了,即
hql="from Teachers tea where tea.name=:teaName and tea.password=:teaPassword";
阅读更多
换一批

(Annotation)org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped ! 请高手解决

02-20

Spring配置文件:rnrn rn com.modelrn rnrn....rnrnUser类:rn@Entity(name="sys_user")rnpublic class User rn private int id;rn private String name;rn private String password;rn private Role role;rn private int flag;rn....rnrnHQL语句:rn"from User"rnrnrn错误:rnorg.springframework.orm.hibernate3.HibernateQueryException: User is not mapped [from User]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]rn at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:657)rn at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)rn at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)rn at com.util.PageDaoImpl.getListForPage(PageDaoImpl.java:41)rn at com.service.impl.UserServiceImplTest.testListForPage(UserServiceImplTest.java:80)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)rn at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)rn at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)rn at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)rn at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)rn at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)rn at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)rn at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)rn at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)rn at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)rn at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)rn at org.junit.runners.ParentRunner.run(ParentRunner.java:236)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)rnCaused by: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]rn at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)rn at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)rn at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:94)rn at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:316)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3228)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3112)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:720)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:571)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:288)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:231)rn at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:254)rn at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)rn at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80)rn at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)rn at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)rn at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)rn at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1651)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.springframework.orm.hibernate3.HibernateTemplate$CloseSuppressingInvocationHandler.invoke(HibernateTemplate.java:1293)rn at $Proxy18.createQuery(Unknown Source)rn at com.util.PageDaoImpl$1.doInHibernate(PageDaoImpl.java:44)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)rn ... 26 morernrn谁知道请回一下, 我在线等。我猜是Annotation的问题

org.hibernate.hql.ast.QuerySyntaxException:

04-19

我在测试使用hibernate过程中,执行hql语句,后台报了这个错,给位大侠帮我分析分析~小弟感激不尽rn后台错误code:rn2012-4-19 16:39:15 org.apache.catalina.core.StandardWrapperValve invokern严重: Servlet.service() for servlet jsp threw exceptionrnorg.hibernate.hql.ast.QuerySyntaxException: User is not mapped [select count(*) from User u where u.username = :username]rn at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)rn at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)rn at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:93)rn at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:277)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)rn at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)rn at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:251)rn at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)rn at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:134)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:101)rn at org.hibernate.engine.query.HQLQueryPlan.(HQLQueryPlan.java:80)rn at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:94)rn at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)rn at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)rn at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1650)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:597)rn at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:342)rn at $Proxy0.createQuery(Unknown Source)rn at com.bjsxt.register.mager.UserManager.exists(UserManager.java:29)rn at org.apache.jsp.RegisterDeal_jsp._jspService(RegisterDeal_jsp.java:73)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)rn at java.lang.Thread.run(Thread.java:619)rn

没有更多推荐了,返回首页