我的代码如下

    @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的错误的更多相关文章

  1. org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped

    因为 String sql2 = "select s from Student s where s.clazz.name=:name"; 此处的 Student 应该为类名.hql ...

  2. 关于Hibernate XXX is not mapped 错误

    我的实体类是这么配置的 @Entity(name="EntityName")  //必须,name为可选,对应数据库中一的个表 就会出现 XXX is not mapped.   ...

  3. hibernate:XXX is not mapped

    hibernate:XXX is not mapped  检查项目中是否将hbm.xml引入

  4. 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 ...

  5. Hibernate 中出现 users is not mapped 问题

    Hibernate 中出现 users is not mapped 问题: 解答:HQL语句中表名应该是ORM映射的类名,所以应该改成:  (如果是用注解生成实体类,那就是注解的那个类)String ...

  6. XXX is not mapped

    这个问题绊了我两次跟头,作为一个3年多开发经验的人,甚是尴尬 java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntax ...

  7. 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 ...

  8. 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 ...

  9. Hql 中 dao 层 以及daoimpl 层的代码,让mvc 模式更直观简洁

    1.BaseDao接口: //使用BaseDao<T> 泛型 ,在service中注入的时候,只需要将T换为对应的bean即可 public interface BaseDao<T& ...

随机推荐

  1. HelloWorld入门程序

    程序开发步骤说明 开发环境搭建完成后我们就可以开发第一个java程序了 java程序开发三步骤:编写.编译.运行 编写Java源程序 1.在本地盘目录下新建文本文件,完整的文件名修改为HelloWor ...

  2. 关于奇妙的 Fibonacci 的一些说明

    奇妙的 Fibonacci,多次模拟赛中出现 同时也是 BZOJ 2813 一 Fibonacci 的 GCD 如果 \(F\) 是 Fibonacci 数列,那么众所周知的有 \(\gcd(F_i, ...

  3. 【洛谷P1754 球迷购票问题】题解

    传送门 卡特兰数经典 \(\texttt{AB}\) 分拆问题. 分析: 题意相当于排列 \(n\) 个 \(\texttt A\) 和 \(n\) 个 \(\texttt B\),使得相邻 \(\t ...

  4. 别无分号只此一家,Python3接入支付宝身份认证接口( alipay.user.certify)体系(2021年最新攻略)

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_184 目前国内身份认证体系做的比较不错的大抵就是支付宝和微信两家了,支付宝的身份验证基于支付宝app的实人认证能力,采用多因子认证 ...

  5. LitJson报错记录

    1.float转double报错 报错类型: Max allowed object depth reached while trying to export from type System.Coll ...

  6. 万答17,AWS RDS怎么搭建本地同步库

    欢迎来到 GreatSQL社区分享的MySQL技术文章,如有疑问或想学习的内容,可以在下方评论区留言,看到后会进行解答 背景说明 AWS RDS 权限受限,使用 mysqldump 的时候无法添加 - ...

  7. Linux上安装jdk 1.8

    1.下载jdk1.8 这里贴个oracle官网链接 https://www.oracle.com/java/technologies/downloads/  里面的jdk版本基本都有 2.将压缩包上传 ...

  8. 美团组件化事件总线方案改进:ModularEventBus

    请点赞关注,你的支持对我意义重大. Hi,我是小彭.本文已收录到 GitHub · AndroidFamily 中.这里有 Android 进阶成长知识体系,有志同道合的朋友,关注公众号 [彭旭锐] ...

  9. 第八十一篇:Vue购物车(二) 名称,图片,价格的渲染

    好家伙, 1,为组件封装属性, 需要封装以下属性: 需要定义的属性 属性名 值的类型 商品名 title String 商品图片 pic String 商品价格 price Number 是否勾选 s ...

  10. 【设计模式】Java设计模式 - 观察者模式

    [设计模式]Java设计模式 - 观察者模式 不断学习才是王道 继续踏上学习之路,学之分享笔记 总有一天我也能像各位大佬一样 @一个有梦有戏的人 @怒放吧德德 分享学习心得,欢迎指正,大家一起学习成长 ...