Using Hibernate JPA to execute native queries in Oracle DB due to their complexity,
I want to catch an exception like " ORA-01722: Nombre non valide "
thrown from SqlExceptionHelper
class, but what was catching is:
class javax.persistence.PersistenceException: could not extract ResultSet
The logger error trace me that but not catched :
jdbc.spi.SqlExceptionHelper : ORA-01722: Nombre non valide
BigDecimal customerId = null;
try {
Query q = entityManager.createNativeQuery(
"select acc.account_id as customerId from Account ...");
customerId = (BigDecimal) q.getSingleResult();
} catch (Exception e) {
logger.info("CLASS : " + e.getClass());
if (e instanceof PersistenceException) { // should display ORA-01722: Nombre non valide ?
logger.info("ERRROR : " + e.getMessage());
throw new SQLException(e.getMessage());
}else
if (e instanceof SQLException) {
logger.info("ERRROR : " + e.getMessage());
throw new SQLException(e.getMessage());
}
logger.info("NOOOOOOOOOOOOO : " + e.getMessage());
throw new Exception(e.getMessage());
}