Hibernate异常: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
来源:互联网 发布:owncloud nginx php 编辑:程序博客网 时间:2024/05/15 06:34
Hibernate异常:org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
1、出现该错误的情况分析
1,配置文件没有加载到hibernate的实体列表里面
2,映射文件的字段与数据库字段不一致,或者名称不一致导致
hql 是 有专门的语法的,不完全同于sql。切记HQL是大小写敏感的,这点不同于SQL。
……QuerySyntaxException…说的就是hql语法有问题,相信你在cmd中使用sql查询中就经常见到下面错误
You have an error in your SQL syntax;
1.看是否忘记将hibernate的映射文件添加到Hibernate.cfg.xml(使用Hibernate时)或者applicationContext.xml中
2.检查表中的字段和映射文件中的字段是否一一对应
3.检查字段名是否使用了数据库中的关键字
4.HQL语句是否正确
2、HQL对比SQL
HQL: Hibernate 查询语言Hibernate 配备了一种非常强大的查询语言,这种语言看上去很像 SQL。但是不要被语法结构上的相似所迷惑,HQL 是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态和关联之类的概念。通常错误就在from 后面的tableName,sql语句中我们当然放的是tableName,而且大小写可以随便写。但是HQL中,我们要在from 后面放对象(Object),比如我们建立了user表,User类。
错误查询
String hql ="from user";Query query=session.createQuery(hql);
正确查询
String hql ="from User";Query query=session.createQuery(hql);
0 0
- Hibernate异常: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
- org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User] 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User] 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User].
- Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User
- org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
- 异常积累:org.hibernate.hql.ast.QuerySyntaxError: User is not mapped. [from User where username=?]
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结 .
- org.hibernate.hql.ast.QuerySyntaxException is not mapped异常
- org.hibernate.hql.ast.QuerySyntaxException: **** is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常总结
- org.hibernate.hql.ast.QuerySyntaxException is not mapped异常
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped 异常处理
- springmvc @RestController restful风格的用法
- BeAlert 一款alert和confirm美化插件(优化)
- session的钝化和活化
- 3.Springboot 之 文件结构和配置文件
- Mybatis 3.1中 Mapper XML 文件 的学习详解
- Hibernate异常: org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
- Java基础知识_day8_(字符串)
- Android Log的封装
- centOS 7安装nodejs npm
- 数据结构——递归
- 多元线性回归模型 matlab代码 自用
- mybatis 分页 RowBounds
- hibernate学习日记3
- Spring Mybatis log4j 在日志文件中显示sql日志