hibernate更新数据库时报了个错误,请教一下大家

不忘初心_且听风吟 发布于 2016/05/14 12:17
阅读 186
收藏 0
以下是报错,是说我HQL语句有问题
Exception in thread "main" org.hibernate.hql.internal.ast.QuerySyntaxException: login is not mapped [update login set pastf=? where id =?]
	at org.hibernate.hql.internal.ast.QuerySyntaxException.generateQueryException(QuerySyntaxException.java:79)
	at org.hibernate.QueryException.wrapWithQueryString(QueryException.java:103)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:218)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:115)
	at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:76)
	at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150)
	at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302)
	at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240)
	at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907)
	at com.wangliang.mail.java_mail.mailHeader(java_mail.java:172)
	at com.wangliang.mail.java_mail.main(java_mail.java:205)
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: login 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:79)
	at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:321)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3704)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3593)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:718)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.updateStatement(HqlSqlBaseWalker.java:375)
	at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:267)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:262)
	at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:190)
	... 9 more

以下是我执行语句的代码

Transaction tran = session2.beginTransaction();
 			Query query = session2.createQuery("update login set pastf=? where id =?");
 			query.setString(0, "账号或密码错误!");
 			query.setString(1, user);
 			query.executeUpdate();
 			tran.commit();





加载中
0
魔力猫
魔力猫
login is not mapped,写得很清楚了。
0
cafelication
cafelication
http://jingyan.baidu.com/article/ceb9fb10dfd6c28cad2ba037.html
返回顶部
顶部