PostgreSQL refcursor handling

100 views
Skip to first unread message

Guy Rouillier

unread,
Aug 25, 2010, 3:16:31 AM8/25/10
to mybati...@googlegroups.com
I'm trying to help out someone on the PostgreSQL mailing list (and
suggested he join this list.) He's trying to return a refcursor from a
stored function as shown in an example here:

http://jdbc.postgresql.org/documentation/83/callproc.html#callproc-resultset-setof

See section "From a Function Returing a refcursor".

I've got this coded up starting from an example I had handy for Oracle
cursors. Here is what I ended up with in the mapper XML:

<select statementType="CALLABLE" id="getAllContacts"
resultMap="contactMap" >
{ call getAllContacts(
#{resultSet, jdbcType=OTHER, mode=OUT,
javaType=java.sql.ResultSet, resultMap=contactMap}
)}
</select>

But I'm getting the following exception. Any ideas if this should work?
Thanks.

ERROR 2010-08-25 03:04:13,234 org.sample.mybatis.Main: Exception caught:
### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: Could not set property
'resultSet' of 'class
org.apache.ibatis.reflection.MetaObject$NullObject' with value
'[org.sample.beans.Contact@12c3327, org.sample.beans.Contact@d24e3f]'
Cause: org.apache.ibatis.reflection.ReflectionException: There is no
setter for property named 'resultSet' in 'class java.lang.Class'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not
set property 'resultSet' of 'class
org.apache.ibatis.reflection.MetaObject$NullObject' with value
'[org.sample.beans.Contact@12c3327, org.sample.beans.Contact@d24e3f]'
Cause: org.apache.ibatis.reflection.ReflectionException: There is no
setter for property named 'resultSet' in 'class java.lang.Class'
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause:
org.apache.ibatis.reflection.ReflectionException: Could not set property
'resultSet' of 'class
org.apache.ibatis.reflection.MetaObject$NullObject' with value
'[org.sample.beans.Contact@12c3327, org.sample.beans.Contact@d24e3f]'
Cause: org.apache.ibatis.reflection.ReflectionException: There is no
setter for property named 'resultSet' in 'class java.lang.Class'
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: Could not
set property 'resultSet' of 'class
org.apache.ibatis.reflection.MetaObject$NullObject' with value
'[org.sample.beans.Contact@12c3327, org.sample.beans.Contact@d24e3f]'
Cause: org.apache.ibatis.reflection.ReflectionException: There is no
setter for property named 'resultSet' in 'class java.lang.Class'
at
org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:61)
at
org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:53)
at
org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:82)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:35)


--
Guy Rouillier

Reply all
Reply to author
Forward
0 new messages