title: How to call an Oracle function from Hibernate with a return parameter?
body: <p>My question is very much like <a href="https://stackoverflow.com/questions/1068974/getting-the-return-value-of-a-pl-sql-function-via-hibernate">Getting the return value of a PL/SQL function via Hibernate</a></p>
  
  <p>I have a function which does some modifications internally and it returns a value.</p>
  
  <p>The original idea was to do something like this:</p>
  
  <pre><code>protected Integer checkXXX(Long id, Long transId)
          throws Exception {
      final String sql = "SELECT MYSCHEMA.MYFUNC(" + id + ", "
              + transId + ") FROM DUAL";
      final BigDecimal nr = (BigDecimal) this.getHibernateTemplate()
              .getSessionFactory().getCurrentSession().createSQLQuery(sql)
              .uniqueResult();
      return nr.intValue();
  }
  </code></pre>
  
  <p>Unfortunately this doesn't work with Oracle. What is the recommended way to do something like this?</p>
  
  <p>Is there a way to extract declared variables from within my statement?</p>