After a ConstraintViolationException when trying to delete an entity, the transastion become inactive so I can't make a rollback ands session.clear() close my session
I work with permenant session
Code:
try {
tx.begin();
deleteObject(template, errorMessage, getSession());
tx.commit();
} catch (Exception ex) {
logger.error("Unable to delete allocation template: " + template.getName(), ex );
ActionMessage error = new ActionMessage(errorMessage, false);
errors.add(error);
} finally {
if (tx != null && tx.isActive()) {
tx.rollback();
}
}