0
我在hibernate上更新hql查詢時遇到問題。更新休眠中的查詢
這裏是我下面的類:
--session configuration
ExamResults examResults = new ExamResults();
examResults.setTitle("cbse board jee");
examResults.setId(2);
String hql = "UPDATE EXAMRESULTS SET TITLE=:TITLE WHERE ID=:ID";
Query query = session.createQuery(hql);
query.setParameter("TITLE", examResults.getTitle());
query.setParameter("ID", examResults.getId());
int result = query.executeUpdate();
System.out.println("Rows Effected=>"+result);
session.save(examResults);
tx.commit();
}
}
在運行類,我得到以下異常:
Exception in thread "main" org.hibernate.hql.ast.QuerySyntaxException: EXAMRESULTS is not mapped [UPDATE EXAMRESULTS SET TITLE=:TITLE WHERE ID=:ID]
at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:181)
...
而且我bean類是在這裏:
什麼應該以正確的方式解決問題?
感謝輸入..它現在... –