Getting output parameter(SYS_REFCURSOR) from Oracle stored procedure in iBATIS 3(by using annotation

Posted by yjacket on Stack Overflow See other posts from Stack Overflow or by yjacket
Published on 2010-04-21T13:29:26Z Indexed on 2010/04/21 13:33 UTC
Read the original article Hit count: 1554

Filed under:
|

I got an example how to call oracle SP in iBATIS 3 without a map file.
And now I understand how to call it.
But I got another problem that how to get a result from output parameter(Oracle cursor).
A part of exception messages is "There is no setter for property named 'rs' in 'class java.lang.Class".
Below is my code. Does anyone can help me?

Oracle Stored Procedure:

CREATE OR REPLACE PROCEDURE getProducts
(
    rs OUT SYS_REFCURSOR
)
IS
BEGIN
    OPEN rs FOR
    SELECT * FROM Products;
END getProducts;

Interface:

public interface ProductMapper
{
    @Select("call getProducts(#{rs,mode=OUT,jdbcType=CURSOR})")
    @Options(statementType = StatementType.CALLABLE)
    List<Product> getProducts();
}

DAO:

public class ProductDAO
{
    public List<Product> getProducts()
    {
        return mapper.getProducts(); // mapper is ProductMapper
    }
}

Full Error Message:

Exception in thread "main" org.apache.ibatis.exceptions.IbatisException: 
### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: Could not set property 'rs' of 'class org.apache.ibatis.reflection.MetaObject$NullObject' with value 'oracle.jdbc.driver.OracleResultSetImpl@1a001ff' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'rs' 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 'rs' of 'class org.apache.ibatis.reflection.MetaObject$NullObject' with value 'oracle.jdbc.driver.OracleResultSetImpl@1a001ff' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'rs' 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)
    at $Proxy8.getList(Unknown Source)
    at com.dao.ProductDAO.getList(ProductDAO.java:42)
    at com.Ibatis3Test.main(Ibatis3Test.java:30)
Caused by: org.apache.ibatis.reflection.ReflectionException: Could not set property 'rs' of 'class org.apache.ibatis.reflection.MetaObject$NullObject' with value 'oracle.jdbc.driver.OracleResultSetImpl@1a001ff' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'rs' in 'class java.lang.Class'
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:154)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.set(BeanWrapper.java:36)
    at org.apache.ibatis.reflection.MetaObject.setValue(MetaObject.java:120)
    at org.apache.ibatis.executor.resultset.FastResultSetHandler.handleOutputParameters(FastResultSetHandler.java:69)
    at org.apache.ibatis.executor.statement.CallableStatementHandler.query(CallableStatementHandler.java:44)
    at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:55)
    at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:41)
    at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:94)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:59)
    ... 7 more
Caused by: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'rs' in 'class java.lang.Class'
    at org.apache.ibatis.reflection.Reflector.getSetInvoker(Reflector.java:300)
    at org.apache.ibatis.reflection.MetaClass.getSetInvoker(MetaClass.java:97)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.setBeanProperty(BeanWrapper.java:146)
    ... 16 more

© Stack Overflow or respective owner

Related posts about java

Related posts about ibatis