报错信息:

ERROR Dispatcher:38 - Exception occurred during processing request: user is not mapped [from user where username = ?]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
org.springframework.orm.hibernate3.HibernateQueryException: user is not mapped [from user where username = ?]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
......
Caused by: org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
......

看到信息的第一反应,映射出错

  1.有无User.hbm.xml文件

  2.该配置文件是否加载到hibernate实体列表中

  3.映射文件字段是否与数据库字段一致,有无误用关键字

--> 依旧错误(既然不是User的错,那就是数据库问题)

  为图方便一开始数据库方言是MySQLDialect,兼容性可能出现问题,改为Mysql5Dialet ,即配置<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>

-->依旧错误(**数据库语句错误?**

  String hql = "from user where username = ?";
  List<User> list = this.getHibernateTemplate().find(hql, username);  错误???

  重点:hql采用实体查询技术,比如下面的例子:String hql=”from User user ”; List list=session.CreateQuery(hql).list(); 上面的代码执行结果是,查询出User实体对象所对应的所有数据,而且将数据封装成User实体对象,并且放入List中返回

所以,上面的hql语句错误,hql语句,一定是对象查询,特别是【tableName】 不要写你要查询的表,而是查询的对象

(此处,user是数据库表名,应该查询的是User对象)

  

SSH执行hql报错:Caused by: org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]的更多相关文章

  1. 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:

    Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...

  2. 报错:Caused by: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): cn.itcast.bos.domain.base.SubArea

    因为 实体类中的主键 是String类型 不能自动为其分配id  所以需要手动设置在service层   model.setId(UUID.randomUUID().toString());

  3. SSH整合报错:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[......]

    非常诡异的报错,信息如下:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(* ...

  4. HQL语句中数据类型转换,及hibernate中createQuery执行hql报错

    一.HQL语句中数据类型转换: 我们需要从数据库中取出序号最大的记录,想到的方法就是使用order by子句进行排序(desc倒序),然后取出第一个对象,可是当初设计数据库时(我们是在原来的数据库的基 ...

  5. idea执行mapreduce报错 Could not locate Hadoop executable: C:\hadoop-3.1.1\bin\winutils.exe

    window执行mapreduce报错 Exception in thread "main" java.lang.RuntimeException: java.io.FileNot ...

  6. 执行mysqld_safe报错:mysqld does not exist or is not executable

    执行mysqld_safe报错: [root@edu data]# /usr/local/mysql5.7/bin/mysqld_safe --user=mysql160427 12:41:28 my ...

  7. 数据库执行sql报错Got a packet bigger than 'max_allowed_packet' bytes及重启mysql

    准备在mysql上使用数据库A,但mysql5经过重装后,上面的数据库已丢失,只得通过之前备份的A.sql重新生成数据库A. 1.执行sql报错 在执行A.sql的过程中,出现如下错误:Got a p ...

  8. selenium执行js报错

    selenium执行js报错 Traceback (most recent call last):    dr.execute_script(js)  File "C:\Python27\l ...

  9. mysql执行update报错1175解决方法

    mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...

随机推荐

  1. c# 实时监控数据库 SqlDependency

    http://blog.csdn.net/idays021/article/details/49661855 class Program { private static string _connSt ...

  2. php数组排序和查找的算法

    1.php算法 // 算法 // 1.冒泡排序 => 思路:​每次循环排列出一个最大的数 // echo '<pre>'; $arr = [ 1,43,54,62,21,66,32, ...

  3. field.setAccessible(true) 简介

    今天查看别人写的代码时,发现这样一句代码,顿时来了兴趣. 需要注意setAccessible 并不是在Field中的,而是在AccessibleObject中. 下面是AccessibleObject ...

  4. C第十八次课

    总结知识点: 指针 1.指针变量 指针变量的定义:例8.1 指针变量的引用:例8.2: 指针变量作为函数参数:例8.3 swap函数,例8.4 比较排序函数 2.指针数组 数组元素的指针:int *p ...

  5. Beta 第七天

    今天遇到的困难: 构造新适配器的时候出现了某些崩溃的问题 ListView监听器有部分的Bug 今天完成的任务: 陈甘霖:完成相机调用和图库功能,完成阿尔法项目遗留下来的位置调用问题,实现百度定位 蔡 ...

  6. Beta 集合

    Beta冲刺序列: Beta凡事预则立 :Beta No.0 Beta冲刺Day1:Beta No.1 Beta冲刺Day2:Beta No.2 Beta冲刺Day3:Beta No.3 Beta冲刺 ...

  7. 简易web服务器

    当通过Socket开发网络应用程序的时候,首先需要考虑所使用的网络类型,主要包括以下三个方面: 1)Socket类型,使用网络协议的类别,如IPv4的类型为PF_INET. 2)数据通信的类型,常见的 ...

  8. 关于webService发布的wsdl中的import问题解决

    大家都知道jdk1.6及以后都支持了对webService的原生态的支持:它在发布时会生成一个wsdl和一个xsd(一个类只生成一个xsd)所以就保留了引用关系,如下: <?xml versio ...

  9. js:防抖动与节流

    http://blog.csdn.net/crystal6918/article/details/62236730

  10. ajax和jquery使用技巧

    1.使用ajax的方法的时候可以使用u方法来获取连接,这样更加安全:alert弹窗的时候需要单引号双引号火狐浏览器会报错!