ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sundar Sankar" <fatboys...@gmail.com>
Subject Re: Re: Question about queryForList and Oracle ref cursors
Date Tue, 11 Mar 2008 02:03:24 GMT
Jason,
           This is what you will have to do,

1. Map an object to the columns being returned from the cursor in your
sq-map-config file. i.e you should have an entry like this
<result id="result" type="ORACLECURSOR" resultType="java.sql.ResultSet"
paramType="OUT"/>

2. You would have mapped your input Parameter in a map and passed it to
getSQLMapClientTemplate.queryForList("ProcName", inputMap").
     This doesnt need to be associated to any List as the List will always
be null.

3.  I have assumed that the parameterName declared for the cursor in the
procedure is result.
The output you would be expecting would be

List<UserDefinedObject> someList = List<UserDefinedObject>inputMap.get
("result");

If you get the result as null, you are either not marking the paramType as
OUT/INOUT in your config or parameter name is wrong and you have to check
the procedure to ensure the parameter name of the resultant cursor is right.

My syntax could have been exactly right but this is the gist of the how to
do it. I am again reiterating the point that queryForList doesnt work for
SP's. It returns a list only for queries. The result of SP is in the map
that you passed. I hope I have helped.

-S

On Mon, Mar 10, 2008 at 6:13 PM, Jason Bennett <Jason.Bennett@3nonline.com>
wrote:

>  One problem I had in this scenario is when I pass parameters to the
> function, and expect a cursor back. I had to map the returning parameter,
> since I had mapped all the in parameters. This prevented me from using
> queryForList() as I wanted to. Am I doing anything wrong, or does passing
> parameters to the SP force me to use the update() method?
>
>
>
>                         jason
>
>
>  ------------------------------
>
> *From:* Ryan Shelley [mailto:12gaugemedia@gmail.com]
> *Sent:* Monday, March 10, 2008 2:38 PM
> *To:* user-java@ibatis.apache.org
> *Subject:* Re: Re: Question about queryForList and Oracle ref cursors
>
>
>
> For reference:
>
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+call+a+stored+procedure
>
> Under: What SqlMapClient Method Should I Use?
> ...
> If your procedure returns a result set (not a result set in an OUT
> parameter, but a result set from the procedure itself), then use *
> queryForList()* or *queryForObject()*. Use queryForList() if you expect
> more than one result object, or queryForObject() if you expect only one
> result Object.
> ...
> If your procedure does not return result sets, or only returns result sets
> in OUT parameters, then use the *update()* method.
>
> -Ryan
>
> On Mon, Mar 10, 2008 at 2:22 PM, Ryan Shelley <12gaugemedia@gmail.com>
> wrote:
>
> In the one you had, you were creating an empty HashMap, executing the
> queryForList method passing in the empty HashMap, and then converting the
> still empty HashMap to a list and returning that to your method.
> queryForList doesn't take an object parameter to store the results in, it
> takes an object parameter to pass variables into your queries.  The return
> value of queryForList is a List of your ResultMapped Models.
>
> -Ryan
>
>
>
> On Mon, Mar 10, 2008 at 2:06 PM, Jesse Reimann <jreimann@ctigroup.com>
> wrote:
>
> Ryan that's exactly what I did that wouldn't work. It returns to me a List that has 10
elements all which are NULL.
>
>
>
>
>
>
>
> Jesse
>
>
>
>
>
>
>

Mime
View raw message