`

【转】org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]

    博客分类:
  • j2ee
阅读更多
org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [from User u where u.id in (:ids)]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:324)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3420)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3309)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:562)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:299)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:247)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:105)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:168)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:221)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:199)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1778)
at com.sjy.dao.impl.UserDaoImpl.findByUserIds(UserDaoImpl.java:26)
at com.sjy.service.impl.UserServiceImpl.findByUserIds(UserServiceImpl.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy16.findByUserIds(Unknown Source)
at com.sjy.service.impl.MessageServiceImpl.sendMessage(MessageServiceImpl.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy17.sendMessage(Unknown Source)
at com.sjy.service.MessageServiceTest.testSendMessage(MessageServiceTest.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
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)

今天遇到这个错误把我整的很狼狈啊!由于粗心在model上面就这样写了@Entity(name="t_user")结果搞了个这样的错误很无奈啊以后要记住!
@Entity
@Table(name="t_user")
还好有人和我出了一样的错误找到了现在转一下希望有帮助
本文转自http://blog.csdn.net/edward_qing_lee/article/details/7753030
分享到:
评论
1 楼 messi_18 2014-11-25  
Thanks very much! I also met this issue and couldn't fix this until saw your post.

相关推荐

    weblogic12 下 org.hibernate.hql.ast.HqlToken

    ### WebLogic 12下org.hibernate.hql.ast.HqlToken冲突解决方案 在使用WebLogic 12部署应用程序时,可能会遇到与`org.hibernate.hql.ast.HqlToken`相关的异常问题。这种异常通常与Hibernate版本之间的不兼容性有关...

    weblogic10.3 org.hibernate.hql.ast.HqlToken报错问题

    在本问题中,我们遇到了一个特定的错误,即“weblogic10.3 org.hibernate.hql.ast.HqlToken报错”,这涉及到Hibernate ORM框架和其在WebLogic上的运行。让我们深入探讨这个问题,以及可能的解决方案。 首先,`org....

    org.hibernate.ejb-library-3.4.0.GA-A

    标题 "org.hibernate.ejb-library-3.4.0.GA-A" 指示这是一个与Hibernate相关的库,特别针对EJB(Enterprise JavaBeans)版本3.4.0,并且是为OSGi环境优化的。描述中提到它适用于在Virgo Jetty服务器上进行Web开发,...

    weblogic10 与hibernate冲突解决方案 linux windows环境全解

    weblogic10 与hibernate冲突解决方案 错误如下:org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken linux windows 环境解决方案全解 Linux 启动脚本添加如下: export USER_...

    hibernate annotations

    **标题:“Hibernate Annotations”** **概述** Hibernate是一个流行的Java对象关系映射(ORM)框架,它简化了在Java应用程序中处理数据库的过程。Hibernate Annotations是Hibernate框架的一个重要组成部分,它...

    hibernate(api 介绍).pdf

    1. org.hibernate.Query Interface:用于向数据库查询对象,封装了 HQL 查询语句,和 SQL 很类似,唯一的区别在于 HQL 是面向对象的。 2. org.hibernate.Criteria Interface:完全封装了基于字符串形式的查询语句,...

    HQL(Hibernate Query Language):

    比如,如果你有一个User类,其有id、username和email属性,对应的SQL查询可能是"SELECT id, username FROM User",而在HQL中,这个查询会写成"SELECT u.id, u.username FROM User u"。这里的"u"是User类的一个别名,...

    Hibernate-HQL.rar_HQL_hibernate hql

    2. 子查询:可以在WHERE或HAVING子句中嵌套HQL查询,如“SELECT u FROM User u WHERE u.id IN (SELECT f.userId FROM Friend f WHERE f.friendId=100)”。 3. 动态HQL:通过Criteria API或Query接口,可以构建动态...

    Hibernate查询语言HQL.PPT

    * 使用 HQL 检索对象:User user = (User) session.createQuery("from User where id = :id").setParameter("id", userID).uniqueResult(); * 使用 HQL 实现复杂查询:from Cat cat where cat.mate.name = 'foo' ...

    hibernate.properties

    #hibernate.query.factory_class org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory ################# ### Platforms ### ################# ## JNDI Datasource #hibernate.connection....

    hibernate(api 介绍).docx

    Query 封装了 HQL(Hibernate Query Language)查询语句,和 SQL 很类似,唯一的区别在于 HQL 是面向对象的。 2. org.hibernate.Criteria Interface:完全封装了基于字符串形式的查询语句,更加面向对象,擅长执行...

    Hibernate_HQL.rar_hibernate HQL_hibernate hql src

    对hibernate的hql进行了详尽的讲解

    Hibernate注解方式、HQL查询

    hql = "from User where name='John'"; users = session.createQuery(hql).list(); ``` 3. **排序与分页**:使用`ORDER BY`进行排序,`setFirstResult`和`setMaxResults`实现分页。如按名字升序排序并获取前10个...

    Hibernate数据检索(HQL)笔记

    ### Hibernate数据检索(HQL)知识点详解 #### 一、简介 Hibernate 是一款开源的对象关系映射(ORM)框架,它允许开发人员将 Java 对象映射到数据库表中的记录,从而极大地简化了数据访问层的开发工作。本文档基于...

    hibernate-src.zip源代码包

    例如,`QueryTranslator`负责将HQL(Hibernate查询语言)转化为SQL,而`TransactionCoordinator`则处理事务相关逻辑。 7. **org.hibernate.event** 包:事件处理相关类,如监听器接口和实现,允许开发者在特定的...

    Hibernate官方网站源代码调试

    重点分析`org.hibernate.hql.ast.ASTQueryTranslatorFactory`和`org.hibernate.criterion.Criterion`接口。 3. **实体管理与状态转换**:实体管理是Hibernate的核心功能之一,包括持久化、加载、更新和删除等操作。...

    Hibernate查询语言(HQL) 语法参考

    Hibernate 查询语言(HQL)语法参考 HQL(Hibernate Query Language)是 Hibernate 框架中的一种强大的查询语言,它类似于 SQL 语句,但是它是完全面向对象的查询语言,可以理解继承、多态和关联等概念。 大小写...

    韩顺平.2011版.hibernate笔记.zip

    笔记将深入解析HQL的基本语法,包括选择(select)、从(from)、条件(where)、分组(group by)和排序(order by)等,以及如何使用HQL进行关联查询。 6. Criteria查询和Criteria API:除了HQL,Hibernate还提供...

    hibernate基础jar包

    7. HQL和Criteria API:Hibernate Query Language(HQL)是Hibernate特有的面向对象的查询语言,类似于SQL,但操作的是对象而非表格。Criteria API是一种类型安全的API,可以动态构建查询,避免SQL注入风险。 8. ...

    hibernate源码包

    Session是与数据库交互的主要接口,SessionFactory是创建Session的工厂,而Query接口则用于执行HQL(Hibernate查询语言)。 2. **org.hibernate.cfg**: 配置相关的类,如Configuration,用于加载Hibernate配置文件...

Global site tag (gtag.js) - Google Analytics