org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped
今天在使用hibernate+springmvc框架,做一个查询时出现了一个错误,sql语句大体为:
select count(id) from address where agency_id in (select id from agency where pids like '%,42,' or id=42) and shflag=0 order by id desc
在mysql查询中能够正常运行,在控制台中报错
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped [select c from com.demi.cms.model.Address c where agency_id in (select id from agency where pids like '%,42,' or id=42) and shflag=0 order by id desc] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert AbstractEntityManagerImpl.java:1750) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source)~~~~~~
提示我们是查询语法错误,后来仔细一想hibernate对大小写敏感,将语句重新更改了一下:
select count(id) from Address where agency_id in (select id from Agency where pids like '%,42,' or id=42) and shflag=0 order by id desc,问题解决!
上一篇: 2017年总结2018年计划
下一篇: java.lang.IllegalStateException: ApplicationEventMulticaster not initialized
推荐阅读
-
moven 部署Sping与mybatis时,Mapped Statements collection does not contain value for Xxxxxxxx
-
【Bug解决】org.apache.ibatis.type.TypeException: The alias ‘xxxx‘ is already mapped to the value ‘xxx‘
-
Mapped Statements collection already contains value for xxx
-
Mybatis:Mapped Statements collection does not contain value for
-
Mapped Statements collection does not contain value for Xxxx
-
Mapped Statements collection does not contain value for XXX
-
Mapped Statements collection does not contain value for
-
Mapped Statements collection does not contain value for xxx
-
[email protected]使用报错:Mapped Statements collection does not contain value for XXX
-
mybatis错误 Mapped Statements collection does not contain value for