字符15不存在Postgres函数

时间:2012-10-03 04:54:28

标签: java hibernate postgresql

我们有一个postgres函数,定义如下:

Schema              | public
Name                | getallocationmap_global
Result data type    | refcursor
Argument data types | OUT v_set refcursor, integer, integer, bigint, integer, 
                      smallint, character varying, bigint, bigint, bigint, bigint, 
                      bigint, bigint, bigint, integer, bigint, double precision,  
                      double precision, bigint, double precision, smallint, double 
                      precision, integer, integer, integer, character varying, integer
Type                | normal

我们目前正在通过hibernate的命名查询在我们的Web应用程序中使用此功能。命名查询按以下方式定义:

<sql-query name="selectAllocationMapByNw_SP" callable="true">
        <return alias="alloc" class="com.zedo.data.dto.AllocationMap">
            <return-property name="id" column="id" />
            <return-property name="channelCode" column="channel_code" />
            <return-property name="creativeId" column="creative_id" />
            <return-property name="priority" column="priority" />
            <return-property name="status" column="status" />
            <return-property name="impressionsAllocated" 
            column="impressions_allocated" />
            <return-property name="impressionsDelivered" 
            column="impressions_delivered" />
            <return-property name="clicksAllocated" column="clicks_allocated" />
            <return-property name="clicksDelivered" column="clicks_delivered" />
            <return-property name="actionsAllocated" column="actions_allocated" />
            <return-property name="actionsDelivered" column="actions_delivered" />
            <return-property name="piactionsDelivered" column="piactions_delivered" />
            <return-property name="timezoneId" column="timezone_id" />
            <return-property name="allocateByDay" column="allocate_by_day" />
            <return-property name="ecpm" column="ecpm" />
            <return-property name="earnedTotal" column="earned_total" />
            <return-property name="vactionsDelivered" column="vactions_delivered" />
            <return-property name="vearnedTotal" column="vearned_total" />
            <return-property name="level" column="level" />
            <return-property name="weight" column="weight" />
            <return-property name="cap" column="cap" />
            <return-property name="durationType" column="duration_type" />
            <return-property name="duration" column="duration" />
            <return-property name="capStatus" column="cap_status" />
            <return-property name="code" column="code" />
        </return>
        { ?=call getallocationmap_global(:nwId, :id, :channelCode, :creativeId, 
         :priority, :status, :impressionsAllocated, :impressionsDelivered, 
         :clicksAllocated, :clicksDelivered, :actionsAllocated, :actionsDelivered, 
         :piactionsDelivered, :timezoneId, :allocateByDay, :ecpm, :earnedTotal, 
         :vactionsDelivered, :vearnedTotal, :level, :weight, :cap, :durationType, 
         :duration, :capStatus, :code) }  
    </sql-query>  

我们访问此命名查询的方式是:

Query query = getSession().getNamedQuery("selectAllocationMapByNw_SP");  

其中getSession()将返回当前的休眠会话。

然后在我们为此查询设置可用参数并以这种方式执行它之后:

List retList = query.list();  

这种方法大部分时间都有效,但在正在运行的应用程序中,它会在给定的时间点突然抛出以下异常:

[org.hibernate.util.JDBCExceptionReporter 280912:063129 WARN ] - SQL Error: 0, SQLState: 25P02
[org.hibernate.util.JDBCExceptionReporter 280912:063129 ERROR] - ERROR: current transaction is aborted, commands ignored until end of transaction block
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  : org.hibernate.exception.GenericJDBCException: could not execute query
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - SQLStateConverter.java::handledNonSpecificException() - 126
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - SQLStateConverter.java::convert() - 114
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - JDBCExceptionHelper.java::convert() - 66
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - Loader.java::doList() - 2231
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - Loader.java::listIgnoreQueryCache() - 2125
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - Loader.java::list() - 2120
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - CustomLoader.java::list() - 312
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - SessionImpl.java::listCustomQuery() - 1722
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - AbstractSessionImpl.java::list() - 165
[AllocationMapSQL 280912:063129 ERROR] - AllocationMapSQL::updateWithStatus() -  - SQLQueryImpl.java::list() - 175
[AllocationMapSQL 280912:063129 ERROR] - ConcreteAllocationMapHibernateDAO::executeSearch() - 111

此外,在db日志中,我们看到以下错误:

ERROR:  function getallocationmap_global(unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown) does not exist at character 15
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.  

我们检查了传递给此函数的所有参数以及参数类型,它们匹配。

P.S。 - 在我们的应用程序中,hibernate操作是通过包含在类路径中的jar文件执行的。

以下是配置:

操作系统 - openSUSE 10.3(X86-64) - 内核\ r \ n(\ l) Hibernate版本 - 3.3.1-GA Postgres - 9.1.4 JDK - 1.6.0-22。 Tomcat - apache-tomcat-7.0.8。 JDBC Jar - postgresql-9.1-901.jdbc3.jar

请告诉我相同的可能原因。提前谢谢。

1 个答案:

答案 0 :(得分:1)

我建议您查看交易块。

ERROR: current transaction is aborted, commands ignored until end of transaction block与一个开放的事务相关联,在该事务中发生错误,并且在该客户端尝试打开另一个事务之后(例如):

BEGIN;
SELECTT 1;  -- ERROR:  syntax error at or near "SELECTT"
BEGIN;      -- ERROR: current transaction is aborted, commands ignored until end of transaction block