1

我们有一个 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.  

我们检查了传递给这个函数的所有参数和参数类型,它们确实匹配。

PS - 在我们的应用程序中,休眠操作是通过包含在类路径中的 jar 文件执行的。

以下是配置:

操作系统 - openSUSE 10.3 (X86-64) - 内核 \r (\l) 休眠版本 - 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

请让我知道可能的原因。提前致谢。

4

1 回答 1

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
于 2012-12-17T13:02:07.417 回答