休止状態での 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クラスはここにあります:
@Entity
@Table(name="EXAMRESULTS")
public class ExamResults implements Serializable{
private int id;
private String title;
private String body1;
private String body2;
private Date resultdate;
private String affiliation;
private int isactive;
private String url;
private String imageurl;
//private CommonsMultipartFile imageurlimg;
private String metatitle;
private String metadescription;
private String metakeywords;
private Date createddate;
--getters & setters
問題を解決するための正しいアプローチは何ですか?