Java 函数调用未正确设置参数

Java 函数调用未正确设置参数,java,hibernate,postgresql,nativequery,Java,Hibernate,Postgresql,Nativequery,我有这个方法: public Long calculateMilisseconds(Calendario calendario, Date inicio, Date fim) throws ApplicationException { try { StringBuffer sb = new StringBuffer(); sb.append("select milissegundos_calendario(?,?,?)")

我有这个方法:

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");
            }
        }
    }
设置参数1和2时,inicio和fim的值实际上是日期实例,看起来一切正常。但我有以下例外:

10:21:53,877 INFO  [STDOUT] 10:21:53,877 ERROR [JDBCExceptionReporter] ERROR: function milissegundos_calendario(integer, unknown, unknown) does not exist.

我正在使用hibernate并对postgresql函数进行本机sql调用。我想不出是怎么回事。有什么想法吗?

参数inicio不是日期,因为它需要整数query.setDate1,inicio;query.setDate2,职能指令手册

函数是如何定义的?创建或替换函数milissegundos_calendariotimestamp(不带时区),timestamp(不带时区),integer返回双精度,当您将日期作为第三个参数传递时,函数需要整数。第一个和第二个参数应该使用java.sql.Timestamp,而不是java.sql.Date或java.util.Date。还有getIdCalendario返回什么?谢谢。。。张贴你的答案。