-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Why refresh()doesn´t work after an insert?
PostPosted: Mon Feb 11, 2008 8:23 am 
Newbie

Joined: Thu Jan 17, 2008 11:27 am
Posts: 4
Hello!

I was trying to refresh a transient object after an insert and it did not work. Could anybody tell me why it doesn´t work for me?

I´m working in a Web Application with Spring and I need to handle the last inserted object in another page.

I have following code:

Code:
public class GenericDao extends HibernateDaoSupport {
...
    public void save(Object obj) {
        getHibernateTemplate().saveOrUpdate(obj);
        getHibernateTemplate().flush();
        getHibernateTemplate().refresh(obj);
    }
...
}


The execution of this code throws following Exception:

org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException: No row with the given identifier exists: [model.Workstep#0]; nested exception is org.hibernate.UnresolvableObjectException: No row with the given identifier exists: [model.Workstep#0]
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:642)
org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:377)
org.springframework.orm.hibernate3.HibernateTemplate.refresh(HibernateTemplate.java:557)
org.springframework.orm.hibernate3.HibernateTemplate.refresh(HibernateTemplate.java:553)

Does anybody know how to solve it?

Best Regards

Wagner


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 12, 2008 4:36 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Try a commit before the refresh.

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject: No Transaction
PostPosted: Tue Feb 12, 2008 5:12 am 
Newbie

Joined: Thu Jan 17, 2008 11:27 am
Posts: 4
schauder wrote:
Try a commit before the refresh.

Thanks Schauder, but I´m not using any transaction here, just the HibernateTemplate, which does all the session stuff for me.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.