Java Code Examples for org.springframework.dao.TransientDataAccessException

Following code examples demonstrate how to use org.springframework.dao.TransientDataAccessExceptionfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.dao.TransientDataAccessExceptionand various code implementation of this class.

    public int addNewBill(GastosMensuales nuevoGasto) {
        GastosMensuales result = null;
        try {
            result = gastosMensualesRepository.save(nuevoGasto);
        }catch (TransientDataAccessException e){
            LOGGER.error("##### ERROR TransientDataAccessException ####" + e.getMessage());
            return 500;
        }catch (NonTransientDataAccessException e){
            LOGGER.error("##### ERROR NonTransientDataAccessException ####" + e.getMessage());
            return 500;
        }catch (ScriptException e){
            LOGGER.error("##### ERROR ScriptException ####" + e.getMessage());
            return 500;
        }catch (SQLGrammarException e){
            LOGGER.error("##### ERROR SQLGrammarException ####" + e.getMessage());
            return 500;
        }catch (Exception e){
            LOGGER.error("##### ERROR Generic ####" + e.getMessage());
            return 500;
        }
        if(result!=null){
            return 201;
        } else {
            return 404;
        }
    } 


    public int addNewDeposit(IngresoMesuales nuevoIngreso) {
        IngresoMesuales result = null;
        try {
                result = ingresoMesualesRepository.save(nuevoIngreso);
        }catch (TransientDataAccessException e){
            LOGGER.error("##### ERROR TransientDataAccessException ####" + e.getMessage());
            return 500;
        }catch (NonTransientDataAccessException e){
            LOGGER.error("##### ERROR NonTransientDataAccessException ####" + e.getMessage());
            return 500;
        }catch (ScriptException e){
            LOGGER.error("##### ERROR ScriptException ####" + e.getMessage());
            return 500;
        }catch (SQLGrammarException e){
            LOGGER.error("##### ERROR SQLGrammarException ####" + e.getMessage());
            return 500;
        }catch (Exception e){
            LOGGER.error("##### ERROR Generic ####" + e.getMessage());
            return 500;
        }
        if(result!=null){
            return 201;
        } else {
            return 404;
        }
    } 

Advertisement
Javadoc
Root of the hierarchy of data access exceptions that are considered transient - where a previously f

ailed operation might be able to succeed when the operation is retried without any intervention by application-level functionality. @author Thomas Risberg @since 2.5 @see java.sql.SQLTransientException

Read More
Advertisement