All,
I here you cannot rollback after committing. So I plan to use this code to rollback if my updates fail:
Code:
try{
session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
session.saveOrUpdate(fa);
}catch(HibernateException ex){
ex.printStackTrace();
log.error(ex.getMessage());
session.getTransaction().rollback();
}
// This closes the session.
// If you call it again, you'll get an exception
session.getTransaction().commit();
parsed = true;
}
Does this look right/well?
Please give your input.