org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped
异常情况:
最近在把一个项目拆分多个 module 的时候数据库查询遇到这个异常:org.hibernate.hql.internal.ast.QuerySyntaxException: Identification is not mapped
JPA 查询方法如下:
public Identification findIdentificationByWxId(String wxId) {
JPAQueryBase query = new JPAQuery(entityManager).from(qIdentification);
query.where(qIdentification.wxId.eq(wxId));
return (Identification) query.fetchOne();
}
异常信息如下:
{
"timestamp": 1548844710242,
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.dao.InvalidDataAccessApiUsageException",
"message": "org.hibernate.hql.internal.ast.QuerySyntaxException: Identification is not mapped [select identification\nfrom Identification identification\nwhere identification.wxId = ?1];
nested exception is java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: Identification is not mapped [select identification\nfrom Identification identification\nwhere identification.wxId = ?1]",
"path": "/user/getUserInfo"
}
解决方法:
在springboot 启动类上加上如下注解便可:
@EntityScan(basePackages = ("cn.xxx.*"))
当一个项目拆分成多个 module 的时候,由于 应用层和实体层已经隔离,所以在应用层启动应用的时候需要扫描 实体。当然如果应用层需要其他 module 中的配置类的话,也是需要添加扫描配置,扫描到其他 module 中的配置类。如:
@SpringBootApplication(scanBasePackages ="cn.xxx.*")
org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped的更多相关文章
- JPA使用中遇到Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped
在写自定义查询时,Query注解中写的JPQL,表名和列名都应该是映射的Java类和属性,不能写表名或者字段名
- SSH整合报错:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped[......]
非常诡异的报错,信息如下:org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [select count(* ...
- 继承映射中的java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: person is not mapped [FROM person]
继承映射中查询对象的过程中报错: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxExcep ...
- java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: student is not mapped
Spring 5.0 +Jpa,使用@Query实现 自定义查询报错: java.lang.IllegalArgumentException: org.hibernate.hql.internal.a ...
- Spring Data JPA开发中遇到的问题1:org.hibernate.hql.internal.ast.QuerySyntaxException: DispatchShift is not mapped
org.hibernate.hql.internal.ast.QuerySyntaxException: T_D_SHIFT_DISPATCH is not mapped 错误原因: 没有映射到表,经 ...
- org.hibernate.hql.internal.ast.QuerysyntaxException:user is not mapped [from User where user_code=? and user_password=?]
初学者,一个很低级的错误吧! 找不到映射,最后发现没把类的Hibernate映射文件 添加到Hibernate核心配置文件中去,所以报了这个异常! 在核心文件中添加映射 <mapping r ...
- ERROR org.hibernate.hql.internal.ast.ErrorCounter unexpected token: form 异常解决
ERROR org.hibernate.hql.internal.ast.ErrorCounter unexpected token: form 异常解决 根据异常提示:我找了我的MySQL语句:果然 ...
- WebLogic使用SSH架构部署遇到org.hibernate.hql.internal.ast.HqlTok
其实这个问题在以前就遇到过,当时解决了,但今天在部署一个测试轻应用的时候一直没有想起来,特此记录一下. 这个问题出现在使用WebLogic(我使用的是10.3.5版本)发布SSH架构的应用.在操作数据 ...
- org.hibernate.hql.ast.QuerySyntaxException: XXX is not mapped
因为 String sql2 = "select s from Student s where s.clazz.name=:name"; 此处的 Student 应该为类名.hql ...
随机推荐
- JWT使用
原文链接:http://www.bleachlei.site/blog/2017/06/09/Nodejs-Expressjs-JWT%EF%BC%8CJWT%E4%BD%BF%E7%94%A8/ J ...
- IIS7二级域名添加同一证书
IIS7二级域名添加同一证书, 先绑定第一个域名到443 ,之后的用以下命令行绑定 cd C:\Windows\System32\Inetsrv\appcmd set site /site.name: ...
- Elastichsearch实践——基本使用
官网文档:https://www.elastic.co/guide/cn/elasticsearch/guide/current/getting-started.html es中的索引.类型.文档可以 ...
- springboot接口返回封装与异常控制
首先,返回有两个状态,status和code status标识response的状态,有2个值:0成功,-1服务错误. code跟业务有关,可以有各种数值,99999服务未知异常,10000参数异常, ...
- spring-mvc访问本地html文件
项目中要用到在线预览word文档,刚开始考虑是要将word转成pdf文件,然后再直接在浏览器打开pdf文档即可, 但是项目部署在Linux下,在网上搜了一下没有找到合适的方法, 后来项目组讨论用POI ...
- LeetCode 9. Palindrome Number(c语言版)
题目: Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same ...
- Justoj 2388最短区间 贪心
2388: 最短区间 Time Limit: 1 s Memory Limit: 128 MB Submit My Status Problem Description 有M种不同颜色的气球 ...
- 做ctf题对malloc的疑问
做cctf pwn printf题目的时候 疑问为什么dir函数会将之前out的name倒叙输出 调试了一下发现当malloc(0xf4)大小时候,例如 第一次分配0x1000的地址,将名字输入到0x ...
- Redis实战 - 4.Key
Redis 键(key) Redis 键命令用于管理 redis 的键. DEL key 该命令用于在 key 存在时删除 key. 127.0.0.1:6379> set w3ckey red ...
- ubuntu 16.04 安装 vscode
ubuntu 安装 vscode sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo apt ...