I am using Hibernate with Spring for my webapp with Declarative tx management. Everything works just fine except that I have run into a situation where I save an object into the database and then I need to get it back with session.refresh( object ) so that I can get all of it's relationships loaded into the session.

I tried committing the Hibernate transaction right before I called the session.refresh(), but it did not work and got: "org.springframework.transaction.TransactionSystem Exception: Could not commit Hibernate transaction; nested exception is org.hibernate.TransactionException: Transaction not successfully started".

code looks like this:
myDao.save( object );
if( x==y )
{
//How do I commit transaction here, so that myDao.save() and myDao.refresh() both //work? or is there other way around?
myDao.refresh( object );
}

Thanks.