I dug into the code and found my issue.

IBatisNet.DataMapper\MappedStatements\MappedStatement.cs
internal IList RunQueryForList(RequestScope request, ISqlMapSession session,
object parameterObject, IList resultObject, RowDelegate rowDelegate)

A single IList is created and appended to, no matter how many resultsets are
returned from the IDataReader.

I attached a patch with 10 minutes worth of code that "works" for my
scenerio as an example.  It is not backwards compatible as it creates a list
for each resultset.  We would probably need a way to opt in to a list of
lists.  A quick idea could be the following.  Does the Java version
have/want anything like this?  We should match their map syntax if they
do...

<select id="GetMultipleResultMap" resultMap="account[], address,
category[]">

select * from accounts

select * from addresses where addressId = 23

select * from categories

</select>

Also when creating empty list, why not create a generic list if we have the
information to do so?  I did that in the patch as well.

Thoughts?

Mike

On 6/12/08, Michael Schall <[EMAIL PROTECTED]> wrote:
>
> Sorry, I should have been more specific.  I think my sql is fine.  I'm
> getting two resultsets back from sql server, but only one from queryForList.
>  The list that comes back has both accounts and categories objects in it
> rather than a list with two elements ( a list of accounts and a list of
> categories).  Looking at the code, a single arraylist is created outside the
> loop of resultsets and then all the objects from both sql resultsets are
> added to the same list.
>
> Mike
>
> On 6/12/08, Ron Grabowski <[EMAIL PROTECTED]> wrote:
>>
>> Try putting a semi-colon after the first select?
>>
>> ----- Original Message ----
>> From: Michael Schall <[EMAIL PROTECTED]>
>> To: [email protected]
>> Sent: Thursday, June 12, 2008 5:46:34 PM
>> Subject: Multiple ResultMap Support
>>
>> I'm trying to use the multiple resultset support in one of my maps.  I
>> only receive one list of objects back.  I expected a list of lists back.  Is
>> the following supported somehow?  If not I suppose I could loop through and
>> split the list by type myself.
>>
>> Thanks
>>
>> Mike
>>
>> <select id="GetMultipleResultMap" resultMap="account, category">
>>
>> select * from accounts
>>
>> select * from categories
>>
>> </select>
>>
>> IList list = sqlMap.QueryForList("GetMultipleResultMap", null);
>>
>> IList<Account> accountList = list[0];
>>
>> IList<Category> categoryList = list[1];
>>
>>
>>
>

Attachment: MappedStatement.patch
Description: Binary data

Reply via email to