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& ...
随机推荐
- 表单中设置了 `keyup.enter.native` 的按键事件,但是回车后没有执行查询,反而会刷新页面
场景 添加属性对话框中,input输入后点击 enter,不会执行绑定的 handleDialogQuery 事件,反而会刷新整个页面: 如果不点击 enter,点击搜索按钮,则是正常的. 又测试:在 ...
- 一个小 Trick
平方变两次 一个状态 \(S\) 有一个贡献,所有状态 \(S\) 组成集合 \(U\) . 然后我们要统计下面这个东西 \[ans=\sum_{S\in U}f^2(S) \] 然后我们就可以看作是 ...
- WindTerm:新一代开源免费的终端工具,GitHub星标6.6k+,太酷了!
继 Tabby.Warp 后,今天再来给大家推荐一款终端神器--WindTerm,完全开源,在 GitHub 上已经收获 6.6k 的 star. https://github.com/kingToo ...
- LuoguP2254 [NOI2005]瑰丽华尔兹 (单调队列优化DP)(用记忆化过了。。。)
记忆化 #include <cstdio> #include <iostream> #include <cstring> #include <algorith ...
- 记一次 ClickHouse 性能测试
前言 在工作场景中,我们会采集工厂设备数据用于智能控制,数据的存储用了 InfluxDB,随着数据规模越来越大,InfluxDB 的性能越来越差,故考虑引入 ClickHouse 分担 InfluxD ...
- 延时任务-基于netty时间轮算法实现
一.时间轮算法简介 为了大家能够理解下文中的代码,我们先来简单了解一下netty时间轮算法的核心原理 时间轮算法名副其实,时间轮就是一个环形的数据结构,类似于表盘,将时间轮分成多个bucket(比如: ...
- Word 的页眉、页脚、页码分别是什么?怎么设置?
页眉:在 Word 文档中,每个页面的顶部区域为页眉.常用于显示文档的附加信息,可以插入时间.图形.公司微标.文档标题.文件名或作者姓名等. 页脚:页脚与页眉的作用相同,都可以作为显示文档的附加信息, ...
- Lua环境搭建编译[Lua5.2+VS2010]
这里是我编译的和一个测试Demo:http://download.csdn.net/detail/allh45601/6783653 大家如果看我下边说的不是很清楚,可以下载这个具体工程: 群:103 ...
- 解决git报错
解决git报错:fatal: unable to access "https://github.com/.../.git/" 1.在git中执行(记得分开执行) git confi ...
- 「题解报告」Blocks
P3503 Blocks 题解 原题传送门 思路 首先我们可以发现,若 \(a_l\) ~ \(a_r\) 的平均值大于等于 \(k\) ,则这个区间一定可以转化为都大于等于 \(k\) 的.我们就把 ...