SSH执行hql报错:Caused by: org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user where username = ?]
报错信息:
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 = ?]的更多相关文章
- 报错Caused by: org.hibernate.AnnotationException: No identifier specified for entity:
Caused by: org.hibernate.AnnotationException: No identifier specified for entity:. 原因: 1.没有给实体类ID 解决 ...
- 报错: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());
- SSH整合报错:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[......]
非常诡异的报错,信息如下:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(* ...
- HQL语句中数据类型转换,及hibernate中createQuery执行hql报错
一.HQL语句中数据类型转换: 我们需要从数据库中取出序号最大的记录,想到的方法就是使用order by子句进行排序(desc倒序),然后取出第一个对象,可是当初设计数据库时(我们是在原来的数据库的基 ...
- 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 ...
- 执行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 ...
- 数据库执行sql报错Got a packet bigger than 'max_allowed_packet' bytes及重启mysql
准备在mysql上使用数据库A,但mysql5经过重装后,上面的数据库已丢失,只得通过之前备份的A.sql重新生成数据库A. 1.执行sql报错 在执行A.sql的过程中,出现如下错误:Got a p ...
- selenium执行js报错
selenium执行js报错 Traceback (most recent call last): dr.execute_script(js) File "C:\Python27\l ...
- mysql执行update报错1175解决方法
mysql执行update报错 update library set status=true where 1=1 Error Code: 1175. You are using safe update ...
随机推荐
- 听翁恺老师mooc笔记(12)--结构中的结构
结构数组: 和C语言中的int,double一样,一旦我们做出一个结构类型,就可以定义这个结构类型的变量,也可以定义这个结构类型的数组.比如下面这个例子: struct date dates[100] ...
- beta冲刺4-咸鱼
昨天的问题: 我的社团数据库表项的处理,代码修改后结果无法显示. 帖子内容无法显示出来. 首页图像未替换 登陆整合没有完成 今天的完成: 服务器部署成功 页面背景修改.(已上传,未确认实装.) 任务截 ...
- 《团队-OldNote-项目总结》
我们小组做的是手机便签的app---OldNote 最开始我们想解决普通手机便签无法进行语音和照片的备忘这一问题,但是由于没有做过拍照和录音的经验怕由于技术原因无法达成目的,就没敢写在需求分析中.当完 ...
- 关于FPGA随笔
verilog与c
- 理解Python迭代对象、迭代器、生成器
作者:zhijun liu链接:https://zhuanlan.zhihu.com/p/24376869来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 本文源自RQ作 ...
- Spring事务注意点
service中未带事务的方法调用了自身带事务的方法时,按下面写法数据是提交不了的. public String getMaxSystemVersionNo() { SystemVersion ver ...
- Linux 磁盘和文件管理系统 文件打包解压备份 VIM、VI编辑器
- bzoj千题计划252:bzoj1095: [ZJOI2007]Hide 捉迷藏
http://www.lydsy.com/JudgeOnline/problem.php?id=1095 点分树+堆 请去看 http://www.cnblogs.com/TheRoadToTheGo ...
- JAVA_SE基础——1.JDK&JRE下载及安装
这是我学了JAVA来写的第一篇博客: 我首先是在传智播客领了张.毕向东老师的免费JAVA学习光盘来学习! 下面我来教大家安装使用JAVA时候必备的JDK 1.首先上甲骨文公司的官方网站下载JDK的安装 ...
- 解决SoapFault (looks like we got no XML document)问题
今天在调试项目的时候出现下面的错误信息: SoapFault looks like we got no XML document (D:\phpStudy\WWW\self.shop.xunmall. ...