Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
程序员文章站
2022-04-28 19:12:28
...
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped [SELECT count(u.id) FROM User u WHERE u.platform = :platform AND u.updatedDate <= :updatedDate]
at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:219) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.internal.AbstractSharedSessionContract.getQueryPlan(AbstractSharedSessionContract.java:605) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
at org.hibernate.internal.AbstractSharedSessionContract.createQuery(AbstractSharedSessionContract.java:714) ~[hibernate-core-5.3.9.Final.jar:5.3.9.Final]
... 79 common frames omitted
解决办法:
原因是你的SQL写错了。
SELECT count(u.id) FROM user u;
这里的表名不是你数据库的表名,而是你写的类名User
正确做法:
SELECT count(u.id) FROM User u;
推荐阅读
-
org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped
-
org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped
-
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value f
-
Caused by: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value
-
【转】org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
-
Hibernate遇到 user is not mapped
-
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
-
JSP:org.hibernate.hql.internal.ast.QuerySyntaxException: catalog is not mapped [from catalog]
-
org.hibernate.hql.internal.ast.QuerySyntaxException: stu1 is not mapped [from stu1]
-
hibernate执行报错org.hibernate.hql.internal.ast.QuerySyntaxException: XXX is not mapped