type collector definition is needed
-----------------------------------

                 Key: IBATIS-447
                 URL: https://issues.apache.org/jira/browse/IBATIS-447
             Project: iBatis for Java
          Issue Type: New Feature
          Components: SQL Maps
    Affects Versions: 2.3.0
            Reporter: Aram Mkhitaryan
            Priority: Critical


I have already posted this feature/improvement in 
http://opensource.atlassian.com/confluence/oss/display/IBATIS/iBATIS+3.0+Whiteboard?focusedCommentId=9142285#comment-9142285

and initial problem is reported in 
https://issues.apache.org/jira/browse/IBATIS-446

I think this may/should be available before 3.0 is released!

The Problem:
 Yesterday I was mapping a result to the java.util.Set

<resultMap ...>
    ...
    <result ...
         javaType="java.util.Set" select="findEmployees" /> 
</resultMap> 

and got a lot of trouble because when the lazy loading was enabled the support 
for Set was broken

Solution:
 and here comes suggestion ...

what if we have a new attribute "collector" or new collector handler mapping 
tag?

<result ...         
    javaType="java.util.Set" select="findEmployees"
    collector="myEmployeeCollector" />

<collectorHandler javaType="XXX" collector="myCollectorForXXX" />

this collector will be responsible for handling selected objects and putting in 
the specified javaType object

this approach will make the code work faster, for now, when lazy loading is not 
enabled,
since the result objects are always collected in java.util.List and then new 
HashMap(list) is called for type conversion,

as you see/know, that constructor copies values from the list, but if we have 
collectors for the defined types (like TypeHandler, TypeHandlerCallback) we 
could add employees even in our domain objects like 
office.addEmployee(employee) 

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to