【发布时间】:2021-02-02 10:46:08
【问题描述】:
我有一个用 @Transactional(rollbackFor = CustomerRollBackException.class) 注释的方法,当我在嵌入 tomcat 中测试它时,它按预期工作。 但是,我将它部署在 jboss wildfly 上,并且相同的方法在抛出异常时不会进行回滚.. 您知道是否需要在 jboss 上进行任何配置?
@Override
@Transactional(rollbackFor = CustomerRollBackException.class)
public void importGenericTable(SheetDTO sheetDTO) throws Exception {
// String tableName, List<Object> rows, UserDTO user
Iterator iterator;
String tableName = sheetDTO.getTableName();
....
try{
..
} catch (ParseException | PersistenceException | SQLGrammarException | ConstraintViolationException e) {
logger.error("importGenericTable. Error " + e);
throw new CustomerRollBackException("E_NPRO_UTIL_IMPORT_0001:" + (countRows + 2));
} catch (CustomerNotFoundException e) {
throw new CustomerRollBackException(e.getMessage());
} catch (Exception e) {
throw new CustomerRollBackException("error desconocido");
}
..
它进入第一个捕获并抛出 CustomerRollBackException 并且回滚没有执行。
【问题讨论】:
标签: java spring-boot jpa transactions rollback