org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
来源:互联网 发布:网络语言1是什么意思 编辑:程序博客网 时间:2024/05/18 01:13
org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
解决办法:
1.看是否忘记将hibernate的映射文件添加到Hibernate.cfg.xml(使用Hibernate时)或者applicationContext.xml中
2.检查表中的字段和映射文件中的字段是否一一对应
3.检查字段名是否使用了数据库中的关键字
4.例如:
下面的Hql语句
from User
其中的user不是表的名字,而是实体类的类名
下面摘自hibernate官方文档
HQL: Hibernate 查询语言
Hibernate 配备了一种非常强大的查询语言,这种语言看上去很像 SQL。但是不要被语法结构上
的相似所迷惑,HQL 是非常有意识的被设计为完全面向对象的查询,它可以理解如继承、多态和
关联之类的概念。
15.1. 大小写敏感性问题
除了 Java 类与属性的名称外,查询语句对大小写并不敏感。 所以 SeLeCT 与 sELEct 以及 SELECT
是相同的,但是 org.hibernate.eg.FOO 并不等价于 org.hibernate.eg.Foo 并且 foo.barSet 也不等
价于 foo.BARSET。
本手册中的 HQL 关键字将使用小写字母。很多用户发现使用完全大写的关键字会使查询语句的可
读性更强,但我们发现,当把查询语句嵌入到 Java 语句中的时候使用大写关键字比较难看。
15.2. from 子句
Hibernate 中最简单的查询语句的形式如下:
from eg.Cat
该子句简单的返回 eg.Cat 类的所有实例。通常我们不需要使用类的全限定名,因为 auto-
import(自动引入)是缺省的情况。所以我们几乎只使用如下的简单写法:
from Cat
为了在这个查询的其他部分里引用 Cat,你将需要分配一个别名。例如:
from Cat as cat
这个语句把别名 cat 指定给类Cat 的实例,这样我们就可以在随后的查询中使用此别名了。关键
字 as 是可选的,我们也可以这样写:
from Cat cat
子句中可以同时出现多个类,其查询结果是产生一个笛卡儿积或产生跨表的连接。
from Formula, Parameter
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- org.hibernate.hql.ast.QuerySyntaxException:XX is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped !
- spring&org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped !
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped hibernate 注解出错
- nested exception is org.hibernate.hql.ast.QuerySyntaxException: users is not mapped. [from users]
- nested exception is org.hibernate.hql.ast.QuerySyntaxException: Product is not mapped [from Product]
- org.hibernate.hql.ast.QuerySyntaxException is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: myaddressbook is not mapped
- org.hibernate.hql.ast.QuerySyntaxException: Enroll is not mapped.
- org.hibernate.hql.ast.QuerySyntaxException: ? is not mapped
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped
- XP环境 boot.ini 关闭 DEP
- XML—尝试对一个XML文档进行增删查改编程
- What is the difference between /dev/ttyUSB and /dev/ttyACM
- C函数解析MP3信息
- 总结一下SQL语句中引号(')、quotedstr()、('')、format()在SQL语句中的用法
- org.hibernate.hql.ast.QuerySyntaxException: XX is not mapped [from XX]
- 要想成功 必备9大好习惯 以及 必须克服的9个坏习惯
- Maven与nexus
- web.xml中load-on-startup的作用
- enable_shared_from_this用法
- 好设计,迁移不费劲
- UVa 11462 - Age Sort
- sublime使用
- 一个例子理解AccessController.doPrivileged()