ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Park <yjac...@paran.com>
Subject Re: How to get a result from output parameter(SYS_REFCURSOR) in iBATIS 3(by using annotation)
Date Fri, 23 Apr 2010 12:20:57 GMT
Alex Park <yjacket <at> paran.com> writes:

> 
> Hi there,
> 
> How to get a result from output parameter(oracle cursor).
> Below is my code and that is not work.
> 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
>    }
> }
> 
> Error Message:
> ### 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 <at> 13f210f' 
> Cause: org.apache.ibatis.reflection.ReflectionException: 
> There is no setter for property named 'rs' in 'class java.lang.Class'
> 
> Thanks,
> Alex
> 

I try another way but it still not work. 

I added @Results annotion into the interface file. 
And set ResultMap ID to "getList-ProductFilter"(I found it via debugging).
And I added one parameter on getList() method.

Interface:
public interface ProductMapper
{
    @Select("call GETPRODUCTS(#{rs,mode=OUT,jdbcType=CURSOR
        javaType=ResultSet,resultMap=getList-ProductFilter})")
    @Results(value={
        @Result(property="productCode",column="productCode"),
        @Result(property="productName",column="productName"),
        @Result(property="publisherCode",column="publisherCode"),
        @Result(property="swGroupCode",column="swGroupCode"),
        @Result(property="swType",column="swType"),
        @Result(property="version",column="version"),
        @Result(property="licenseType",column="licenseType"),
        @Result(property="price",column="price")			
    })
    @Options(statementType = StatementType.CALLABLE)
    List<Product> getList(ProductFilter filter);
}

ProductFilter:
public class ProductFilter
{
    private ResultSet rs;

    public ResultSet getRs() {
        return rs;
    }

    public void setRs(ResultSet rs) {
        this.rs = rs;
    }
}

DAO:
public List<Product> getList()
{
    return mapper.getList(new ProductFilter());
}

Finally, I got an new error message.

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 'com.domain.filter.ProductFilter@13f210f' 
with value '[productCode:1, productName:1, publisherCode:1, swGroupCode:1
, swType:1, version:1]' 

Cause: java.lang.IllegalArgumentException: argument type mismatch




I would appreciate if anyone can let me know the corrections as this.

Thanks,
Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message