title: Java Catch and Display SqlExceptionHelper
body: <p>Using Hibernate JPA to execute native queries in Oracle DB due to their complexity,
  I want to catch an exception like <code>" ORA-01722: Nombre non valide "</code> thrown from <code>SqlExceptionHelper</code> class, but what was catching is: </p>
  
  <blockquote>
    <p>class javax.persistence.PersistenceException: could not extract
    ResultSet</p>
  </blockquote>
  
  <p>The logger error trace me that but not catched :</p>
  
  <pre><code>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());
  }
  </code></pre>