我的代码如下

    @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. python开发环境配置(Windows)

    简介 由于在搭建pyhon开发环境时会出现各种各样的问题,因此将这些问题记录下来 1.下载python 从官网下载对应系统的python版本(最新稳定版即可):官网地址为:python下载地址, 建议 ...

  2. 移动web开发02

    虽然视口很多,但是我们只用一个.就是理想视口. 单标签. 原本是高宽都300的.后来变成移动端后没有变成300/750,也不是300/1334.而是占据了一大半(300/375).甚至375就满屏了. ...

  3. BZOJ3262/Luogu3810 陌上花开 (三维偏序,CDQ)

    一个下午的光阴之死,凶手是细节与手残. 致命的一枪:BIT存权值时: for(; x <= maxx; x += x&-x) t[x] += w; //for(; x <= n; ...

  4. @babel/runtime 和 @babel/plugin-transform-runtime 两个的作用是什么

    Babel 最基础的功能就是将采用 ECMAScript 2015+ 语法编写的代码转换为向后兼容的 JavaScript 语法,以便能够运行在当前和旧版本的浏览器或其他环境中. 最基础的依赖包也就是 ...

  5. 【Azure 应用服务】在 App Service for Windows 中自定义 PHP 版本的方法

    问题描述 在App Service for Windows的环境中,当前只提供了PHP 7.4 版本的选择情况下,如何实现自定义PHP Runtime的版本呢? 如 PHP Version 8.1.9 ...

  6. 概述:基于事件的优化方法 / 事件驱动优化 / Event-Based Optimization / EBO

    大家好,我是月出 本文基于这篇综述,介绍了 事件驱动优化(Event-Based Optimization, EBO). 事件驱动优化,是一种建模现实场景.做优化的思路,理论和 MDP / 强化学习很 ...

  7. 动态规划——leetcode55、跳跃游戏

    1.题目描述:  2.解题方法:动态规划 动态规划解题步骤: 1.确定状态: 最后一步:如果能跳到最后一个下标,我们考虑他的最后一步到n-1(最后一个下标),这一步是从 i 跳过来的,i<n-1 ...

  8. 【HTML】学习路径3-段落标签和标题标签

    第一章:标题标签 <h1>  </h1> <h2>  </h2> 等等... 数字越大,字体尺寸越小. <!--标题会加粗.独占一行--> ...

  9. MQ系列4:NameServer 原理解析

    MQ系列1:消息中间件执行原理 MQ系列2:消息中间件的技术选型 MQ系列3:RocketMQ 架构分析 1 关于NameServer 上一节的 MQ系列3:RocketMQ 架构分析,我们大致介绍了 ...

  10. 在Linux下配置RealVNC和TigerVNC

    作者:alittlemc | 更新中 | 原创文章,可能有技术理解错误,欢迎指正,请与我联系,谢谢! 命令和快速总结 realvnc创建# :会话id -name 取名字 -depth 色深 -geo ...