[
https://issues.apache.org/jira/browse/IBATIS-352?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12462127
]
Paul Benedict commented on IBATIS-352:
--------------------------------------
I actually solved the problem, but it is totally not obvious :-)
<typeHandler javaType="org.xyz.Role" ... />
<resultMap id="userMap" class="User" groupBy="id">
<result property="id" column="u_id" />
<result property="roles" resultMap="NameSpace.roleResult"
</resultMap>
<resultMap id="roleResult" class="Role">
<result property="value" column="ur_id" />
</resultMap>
It turns out when there is a result map with just one item in it, and you
provide a type handler, Ibatis will treat it "like" a primitive type -- the
first result is the value. Who would have thought!!
This is really not obvious at all. I recommend IBATIS adds a resultClass to the
<result> tag so that users don't need yet another map to translate single
values (enums and primitives in collections especially). Hence this would
become:
<resultMap id="userMap" class="User" groupBy="id">
<result property="id" column="u_id" />
<result property="roles" column="ur_id" resultClass="Role" />
</resultMap>
> Problems with Complex Properties + Sets & enums
> -----------------------------------------------
>
> Key: IBATIS-352
> URL: https://issues.apache.org/jira/browse/IBATIS-352
> Project: iBatis for Java
> Issue Type: Bug
> Components: SQL Maps
> Affects Versions: 2.2.0
> Environment: JDK 1.5, IBATIS SQL Maps 2.2.0.638, Spring 2.0
> Reporter: Andrew Bethell
> Attachments: domain.zip, join-resultmap with enum.txt, lazy-load with
> set.txt, sqlmap.zip
>
>
> There doesnt seem to be support for lazy-loading complex properties of type
> 'java.util.Set', only List collections - (stack trace attached to this
> issue).
> I have to use Set collections at the moment, as when I upgraded from IBATIS
> SQLMaps 2.17 to 2.22, the 'groupBy' attribute for resultmaps did not seem to
> make data in (List) complex properties distinct by ID, where as in version
> 2.17 this was the case.
> Strangely though, when loading complex properties with joins+resultMaps, Set
> properties work correctly - except when items in the Set contain enum types
> (stack trace attached for this too).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira