HQL中出现XXX is not mapped的错误
我的代码如下
@Test
public void testCollection(){
String hql = "from Order where orderItems is not empty"; Query query = session.createQuery(hql); List<Order> orders = query.list(); for(Order o:orders){ System.out.println(o.getCustomer().getName()); System.out.println(o.getAmount()); } }
由于没有在HQL语句中使用别名,而包里存在一个OrderItem的类,使其编译无法通过,所以将代码改写如下即可运行。
@Test
public void testCollection(){
String hql = "from Order o where o.orderItems is not empty"; Query query = session.createQuery(hql); List<Order> orders = query.list(); for(Order o:orders){ System.out.println(o.getCustomer().getName()); System.out.println(o.getAmount()); } }
HQL中出现XXX is not mapped的错误的更多相关文章
- org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped
因为 String sql2 = "select s from Student s where s.clazz.name=:name"; 此处的 Student 应该为类名.hql ...
- 关于Hibernate XXX is not mapped 错误
我的实体类是这么配置的 @Entity(name="EntityName") //必须,name为可选,对应数据库中一的个表 就会出现 XXX is not mapped. ...
- hibernate:XXX is not mapped
hibernate:XXX is not mapped 检查项目中是否将hbm.xml引入
- 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 u ...
- Hibernate 中出现 users is not mapped 问题
Hibernate 中出现 users is not mapped 问题: 解答:HQL语句中表名应该是ORM映射的类名,所以应该改成: (如果是用注解生成实体类,那就是注解的那个类)String ...
- XXX is not mapped
这个问题绊了我两次跟头,作为一个3年多开发经验的人,甚是尴尬 java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntax ...
- org.hibernate.hql.ast.QuerySyntaxException: Student is not mapped [from Student as stu where stu.sclass=?]
java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: t_aty_disease is not ...
- org.hibernate.hql.ast.QuerySyntaxException: tb_voteoption is not mapped [from tb_voteoption where voteID=?]
转自:https://www.cnblogs.com/albert1017/archive/2012/08/25/2656873.html org.hibernate.hql.ast.QuerySyn ...
- Hql 中 dao 层 以及daoimpl 层的代码,让mvc 模式更直观简洁
1.BaseDao接口: //使用BaseDao<T> 泛型 ,在service中注入的时候,只需要将T换为对应的bean即可 public interface BaseDao<T& ...
随机推荐
- 使用flex弹性布局代替传统浮动布局来为微信小程序写自适应页面
原文转载自「刘悦的技术博客」https://v3u.cn/a_id_109 我们知道,写习惯了前端的人,一般切图后布局页面的话,上手最习惯的是基于盒子模型的浮动布局,依赖 display 属性 + p ...
- LitJson报错记录
1.float转double报错 报错类型: Max allowed object depth reached while trying to export from type System.Coll ...
- Mysql8基础知识
系统表都变为InnoDb表 从MySQL 8.0开始,系统表全部换成事务型的InnoDB表,默认的MySQL实例将不包含任何MyISAM表,除非手动创建MyISAM表 基本操作 创建数据表的语句为CR ...
- 使用jmh框架进行benchmark测试
性能问题 最近在跑flink社区1.15版本使用json_value函数时,发现其性能很差,通过jstack查看堆栈经常在执行以下堆栈 可以看到这里的逻辑是在等锁,查看jsonpath的LRUCach ...
- 臭名远扬之 goto 语句
C 语言自学之 goto 语句 Dome1:以下程序实现从控制台输出1-10,使用goto语句,实现当输出完3之后跳出循环体. 1 #include <stdio.h> 2 3 int m ...
- Luogu3871 [TJOI2010]中位数 (平衡树)
"#define int long long" 导致100pts \(\rightarrow\) 80pts #include <iostream> #include ...
- Luogu2251 质量检测 (ST表)
我怎么开始划水了... #include <iostream> #include <cstdio> #include <cstring> #include < ...
- java-Servlet-cookie and session
1 状态管理 a) 什么是状态管理?将浏览器与web服务器之间多次交互当做一个整体处理,并且将多次交互涉及的数据(即状态)保存下来. b) 如何进行状态管理? 可以将状态保存在客户端将状态保存到浏览器 ...
- MySQL启动报:[ERROR] The server quit without updating PID file
修改配置后MySQL启动不了,报错: [root@localhost mysql]# service mysql restart Starting MySQL...[ERROR] The server ...
- 网络编程与socket套接字
网络编程与socket套接字 传输层 PORT协议 port是一种接口,数据通过它在计算机和其他设备(比如打印机,鼠标,键盘或监视器)之间,网络之间和其他直接连接的计算机之间传递 TCP协议 传输 ...