org.hibernate.hql.ast.QuerySyntaxException
程序员文章站
2022-04-13 08:40:56
...
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: user is not mapped [from user as u where u.name=:name and u.password=:password]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
at com.redarmy.LoginAction.UserDao.checkUser(UserDao.java:117)
at com.redarmy.LoginAction.UserDao.main(UserDao.java:148)
解决方法:
把:from中的user改成对应的javabean User.java的名字:User即可
推荐阅读
-
org.hibernate.hql.ast.QuerySyntaxException
-
【转】org.hibernate.hql.ast.QuerySyntaxException: User is not mapped [from User]
-
org.hibernate.hql.ast.QuerySyntaxException: is not mapped [from ]怎么解决
-
org.hibernate.hql.ast.QuerySyntaxException
-
org.hibernate.hql.ast.QuerySyntaxException
-
org.hibernate.hql.ast.QuerySyntaxException
-
org.hibernate.hql.ast.QuerySyntaxException: xxx is not mapped