ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From José Renato <rmflor...@gmail.com>
Subject Postgre Cursor mapping
Date Fri, 15 Jan 2010 16:03:59 GMT
Hi All,

I am trying to map a Postgre function using Cursor. The problem is how to
map those results. Follows:

//----------------------------
-----------------------------------------------------------
<sqlMap namespace="app">
<select id="searchSources" parameterMap="map"
resultMap="searchSourcesResult">
    BEGIN;
        select * from f_search_sources(#one#,#two#, 'total', 'list');
        FETCH ALL FROM total;
        FETCH ALL FROM list;
    COMMIT;
</select>

<resultMap id="searchSourcesResult" class="com.app.PagedList">
    <result property="size" javaType="int" column="total" jdbcType="INT" />
    <result property="pagedList" resultMap="app.searchPagedList" />
</resultMap>

<resultMap id="searchPagedList" class="com.app.Source">
    <result property="name" javaType="java.lang.String" column="id_source"
jdbcType="VARCHAR" />
</resultMap>

</sqlMap>

//---------------------------------------------------------------------------------------
package com.app;
public class PagedList<T> {
    private int size;
    private List<T> pagedList;
    //all the getters and setters...
}
//---------------------------------------------------------------------------------------
package com.app;
public class Source {
    private String name;
    //all the getters and setters...
}
//---------------------------------------------------------------------------------------


That SQL code works fine in a SQL console, but when I try to retrieve data
with iBatis it doesn't.

java.langException: com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in com/app/ibatis/postgre/sql-map-app.xml.
--- The error occurred while applying a result map.
--- Check the app.searchSourcesResult.
--- Check the result mapping for the 'size' property.
--- Cause: org.postgresql.util.PSQLException: Column name total not found in
ResultSet.
...

Can some good soul give me some orientation?

Best regards,
José.

Mime
View raw message