wrap it within a transaction.
something like this:
Code:
Session hibernateSession = null;
Transaction transaction = null;
try
{
if (orderType != null)
{
hibernateSession = HibernateManager.currentSession();
transaction = hibernateSession.beginTransaction();
hibernateSession.saveOrUpdate(orderType);
transaction.commit();
saved = true;
}
}
catch (HibernateException e)
{
try
{
transaction.rollback();
}
catch (Exception ex)
{
logger.warn("Exception encountered rolling back transaction due to HibernateException in " + sMethodName + Utilities.getStackTrace(ex));
}
logger.warn("Hibernate Exception in " + sMethodName + Utilities.getStackTrace(e));
}
finally
{
// Blah Blah
}