ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Raffeiner" <Stefan.Raffei...@aimsoftware.com>
Subject GroupByStrategy and resultObject
Date Mon, 03 Sep 2007 14:23:22 GMT
Hello all,

I'm relatively new to IBatis, so please bear with me if I'm totally
wrong on this :-)

When using IBatis DataMapper with "pre-instantiated" result objects and
a GroupBy-property indicated in the mapping file, the result objects
never get filled. I.e., with

Customer result1 = new Customer(); 
Customer result2 = mMapper.QueryForObject("stmt", paramObject,
result1));

result1 will always be empty (and thus different from result2, which is
populated correctly), even if the query only returns 1 result object.
The reason for this is that in File ResultMapStrategy.cs (which maps
non-grouping result sets, as far as I understood), line 53 queries for
the resultObject being null, and only creates a new instance if needed:

ResultMapStrategy.cs
line 49:   object outObject = resultObject;
line 53:   if (outObject == null)
line 67:   outObject = resultMap.CreateInstanceOfResult(parameters);

On the other hand, in file GroupByStrategy.cs, there is no such
condition present. Instead, the outObject will always be overwritten
with a new instance (line 83), even though outObject gets assigned in
line 55 with the value stored in parameter resultObject:

GroupByStrategy.cs, 
line 55:   object outObject = resultObject;
line 83:   outObject = resultMap.CreateInstanceOfResult(null);

Now since I'm new to IBatis, I'm reluctant to call this a bug until I
fully understand whether this behaviour is desired - any suggestions?

Thank you!
Stefan


Mime
View raw message