You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Christopher John Gores (JIRA)" <ib...@incubator.apache.org> on 2004/12/16 01:56:00 UTC

[jira] Created: (IBATIS-28) Support multiple results from Stored Procedures

Support multiple results from Stored Procedures
-----------------------------------------------

         Key: IBATIS-28
         URL: http://nagoya.apache.org/jira/browse/IBATIS-28
     Project: iBatis for Java
        Type: Improvement
  Components: SQL Maps  
    Versions: 2.0.8    
 Environment: All
    Reporter: Christopher John Gores


It seems there is no support for multiple results being returned by a stored procedure (i.e. statement.getMoreResults()).  Unfortunately, that's a showstopper for my new project that needs to call legacy procedures.

Suggested solution:  Allow a statement to use an ordered collection of resultMaps, either by creating a new <resultMapSet> tag, allowing <resultMap> to nest, or by allowing the statement's resultMap attribute to hold a comma-separated list of resultMaps.  The resulting object would have to be a List of mapped result objects.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-28) Support multiple results from Stored Procedures

Posted by "Brandon Goodin (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-28?page=comments#action_66492 ]
     
Brandon Goodin commented on IBATIS-28:
--------------------------------------

If you have multiple results coming back then i think the select or procedure should have multiple resultMaps that it can be assigned to (resultMap="resultMapOne,resultMap2").  Then i'd think you could pass this back as an Object[] and/or List[]. It might require a couple different methods added to the SqlExecutor to return a multiple result object[] (public Object[] queryForMultipleObject(...), public List[] queryForMultipleList(...)).

Thoughts?

> Support multiple results from Stored Procedures
> -----------------------------------------------
>
>          Key: IBATIS-28
>          URL: http://issues.apache.org/jira/browse/IBATIS-28
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.0.8
>  Environment: All
>     Reporter: Christopher John Gores

>
> It seems there is no support for multiple results being returned by a stored procedure (i.e. statement.getMoreResults()).  Unfortunately, that's a showstopper for my new project that needs to call legacy procedures.
> Suggested solution:  Allow a statement to use an ordered collection of resultMaps, either by creating a new <resultMapSet> tag, allowing <resultMap> to nest, or by allowing the statement's resultMap attribute to hold a comma-separated list of resultMaps.  The resulting object would have to be a List of mapped result objects.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-28) Support multiple results from Stored Procedures

Posted by "John Purcell (JIRA)" <ib...@incubator.apache.org>.
    [ http://issues.apache.org/jira/browse/IBATIS-28?page=comments#action_12360919 ] 

John Purcell commented on IBATIS-28:
------------------------------------

I would say this would be a very useful  since a number of databases (MSSQL, Sybase, and now even MySQL) support this kind of feature. While I'm less concerned on how the resultMaps are assigned in the xml files (resultMap="resultMapOne,resultMap2" or a <resultMapSet> tag is fine), I think that the above suggestions to the API are a bit kludgy at best since they would envolve a huge amount of casting (at least in 1.4.x era code). 

Why not use what's at the heart of the API anyway: the RowHandler

I'd say change queryWithRowHandler(String statementName, Object parameterOjbect, RowHandler rowHandler) to
queryWithRowHandler(String statementName, Object parameterOjbect, RowHandler[] rowHandler), where each entry in the rowHandler array corresponds with each resultSet. DefaultRowHandler could be made public (as in moved to com.ibatis.sqlmap.client.event) and extended to have a getObject() method to get the first entry in the list (which is what queryForObject does anyway) and other RowHandlers could be added (such as a MapRowHandler).

The above would get around some thornier aspects of using multiple resultsets. For instance, say you had a proc/select statement that returned three result sets and you wanted them to be mapped to a list, an object, and a map. The example code would be the following:

<pre>
DefaultRowHandler listHandler = new DefaultRowHandler();
DefaultRowHandler objectHandler = new DefaultRowHandler();
MapRowHandler mapHandler = new MapHandler("ID"); // where "ID" is the column in the resultSet that corresponds to the map key

sqlMapClient.queryWithRowHandler("myProcStatemet", null, RowHandler[] { listHandler, objectHandler, mapHandler });

List myList = listHandler.getList();
Object myObject = objectHandler.getObject();
Map myMap = mapHandler.getMap();
</pre>

It would, of course, be up to the user to make sure that the order of the RowHandlers are correct. queryWithRowHandler(String statementName, Object parameterOjbect, RowHandler rowHandler)  would internally call queryWithRowHandler(statementName, parameterOjbect, RowHandler[] { rowHandler}) and be deprecated. 

Thoughts?


> Support multiple results from Stored Procedures
> -----------------------------------------------
>
>          Key: IBATIS-28
>          URL: http://issues.apache.org/jira/browse/IBATIS-28
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.0.8
>  Environment: All
>     Reporter: Christopher John Gores

>
> It seems there is no support for multiple results being returned by a stored procedure (i.e. statement.getMoreResults()).  Unfortunately, that's a showstopper for my new project that needs to call legacy procedures.
> Suggested solution:  Allow a statement to use an ordered collection of resultMaps, either by creating a new <resultMapSet> tag, allowing <resultMap> to nest, or by allowing the statement's resultMap attribute to hold a comma-separated list of resultMaps.  The resulting object would have to be a List of mapped result objects.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-28) Support multiple results from Stored Procedures

Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
     [ http://nagoya.apache.org/jira/browse/IBATIS-28?page=comments#action_56777 ]
     
Clinton Begin commented on IBATIS-28:
-------------------------------------

A fair suggestion.  It's been talked about before.   

In your opinion, what would be returned from queryForObject() and/or queryForList()??

A collection of objects and/or collections and/or a combination of both?

Cheers,
Clinton

> Support multiple results from Stored Procedures
> -----------------------------------------------
>
>          Key: IBATIS-28
>          URL: http://nagoya.apache.org/jira/browse/IBATIS-28
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.0.8
>  Environment: All
>     Reporter: Christopher John Gores

>
> It seems there is no support for multiple results being returned by a stored procedure (i.e. statement.getMoreResults()).  Unfortunately, that's a showstopper for my new project that needs to call legacy procedures.
> Suggested solution:  Allow a statement to use an ordered collection of resultMaps, either by creating a new <resultMapSet> tag, allowing <resultMap> to nest, or by allowing the statement's resultMap attribute to hold a comma-separated list of resultMaps.  The resulting object would have to be a List of mapped result objects.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


[jira] Commented: (IBATIS-28) Support multiple results from Stored Procedures

Posted by "Frederick A. Daria (JIRA)" <ib...@incubator.apache.org>.
     [ http://issues.apache.org/jira/browse/IBATIS-28?page=comments#action_59490 ]
     
Frederick A. Daria commented on IBATIS-28:
------------------------------------------

Hi,

I also believe that this feature is very useful, I'm currently working on a financial application calling a Cobol based stored procedure that returns 2 Cursors as result set and we're using iBATIS all throughout the project, but in this case, I had to code it in JDBC to be able to retrieve all the results.

I'm not sure as to how we could interface with it in code, but I guess sql map client could either return a map of objects or a collection of collections or something related to that.

Cheers,
Darrix

> Support multiple results from Stored Procedures
> -----------------------------------------------
>
>          Key: IBATIS-28
>          URL: http://issues.apache.org/jira/browse/IBATIS-28
>      Project: iBatis for Java
>         Type: Improvement
>   Components: SQL Maps
>     Versions: 2.0.8
>  Environment: All
>     Reporter: Christopher John Gores

>
> It seems there is no support for multiple results being returned by a stored procedure (i.e. statement.getMoreResults()).  Unfortunately, that's a showstopper for my new project that needs to call legacy procedures.
> Suggested solution:  Allow a statement to use an ordered collection of resultMaps, either by creating a new <resultMapSet> tag, allowing <resultMap> to nest, or by allowing the statement's resultMap attribute to hold a comma-separated list of resultMaps.  The resulting object would have to be a List of mapped result objects.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira