Hi all
I am using hibernate to upload the the news object in my project.
The code for the updating function is as follows :
public static boolean updateNews(News obj , int id) {
Session session = null;
Transaction tx = null;
boolean flag = false;
try {
session = sessionFactory.openSession();
tx = session.beginTransaction();
News news = (News)session.load(News.class,new Integer(id));
news = obj;
String title3 = news.getTitle();
session.update(news);
tx.commit();
flag = true;
} catch(RuntimeException REx) {
if(tx != null) {
tx.rollback();
}
REx.printStackTrace();
throw REx;
} finally {
session.close();
}
return flag;
}
This function is being called in struts action by the following way :
NewsForm news = (NewsForm) form;
News bean = new News();
BeanUtils.copyProperties(bean, news);
NewsDataOperations.updateNews(bean, id)
where id is the rowid for the corresponding row to be updated.
While this function executes i get the following exception :
org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1
i have tried but unable to solve it
if anybody have any idea please help me
thanx