Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1

843840Aug 22 2007 — edited Aug 22 2007
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 19 2007
Added on Aug 22 2007
2 comments
354 views