I have this method:
public Long calculateMilisseconds(Calendario calendario, Date inicio, Date fim) throws ApplicationException {
try {
StringBuffer sb = new StringBuffer();
sb.append("select milissegundos_calendario(?,?,?)");
Session session = HibernateUtil.currentSession();
SQLQuery query = session.createSQLQuery(sb.toString());
query.setInteger(0, calendario.getIdCalendario());
query.setDate(1, inicio);
query.setDate(2, fim);
return (Long) query.uniqueResult();
} catch (ApplicationException ae) {
throw ae;
} catch (Exception e) {
log.error(e);
log.error("# CalendarioHibernateDAO.calcularMilissegundosProdutivos(calendario, inicio, fim) : Long");
throw new ApplicationException("ERRO.1", new String[]{"CalendarioHibernateDAO.calcularMilissegundosProdutivos"}, e, ApplicationException.ICON_ERRO);
} finally {
try {
HibernateUtil.closeSession();
} catch (Exception e) {
log.error(e);
log.error("# CalendarioHibernateDAO.calcularMilissegundosProdutivos(calendario, inicio, fim) : Long");
}
}
}
When setting parameter #1 and #2, the values for inicio and fim are actually Date instances, look like that everything is ok. But I got the following exception:
10:21:53,877 INFO [STDOUT] 10:21:53,877 ERROR [JDBCExceptionReporter] ERROR: function milissegundos_calendario(integer, unknown, unknown) does not exist.
I am using hibernate and making a native sql call for a postgresql function. I can't figure out what is wrong. Any thoughts?