Hibernate遇到 user is not mapped
程序员文章站
2022-04-28 22:50:31
...
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: User is not mapped
在执行HQL语句时,遇到这个错误。
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: t_user is not mapped
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:171)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:91)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:76)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:320)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3678)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3567)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:708)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:564)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:301)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:249)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)
... 49 more
原因一般都是,HQL错误,而hql里面的表名不是数据库里面的表面,而应该是数据库表所映射的类的名字;
例如数据库表名为t_user, 类名为user,这里HQL语句应该使用user。问题得到解决。
上一篇: Gradle打包SpringBoot项目成为可执行jar包
下一篇: Vue.js动态设置data值
推荐阅读
-
org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped
-
org.hibernate.hql.internal.ast.QuerySyntaxException: agency is not mapped
-
Hibernate MySQL方言配置遇到的坑
-
Hibernate 遇到的坑
-
SSM 集成 hibernate validator中遇到的坑
-
Caused by: org.hibernate.service.spi.ServiceException Hibernate框架JDBC配置连接MySQL8.0.1遇到的问题及解决方法
-
今天升级hibernate3.2GA遇到一个很奇怪的问题(谢谢大家,已解决) HibernateMySQLCacheSpringOpenSource
-
mysql-MySQL 在hibernate中遇到的主键生成问题
-
mysql-MySQL 在hibernate中遇到的主键生成问题
-
【转】org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]