[
https://issues.apache.org/jira/browse/IBATIS-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506972
]
Jeff Butler commented on IBATIS-442:
------------------------------------
Please do not use JIRA for support requests. Use the mailing lists.
Also, posting the same thing to multiple JIRA tickets is rude.
> Nested groupBy
> --------------
>
> Key: IBATIS-442
> URL: https://issues.apache.org/jira/browse/IBATIS-442
> Project: iBatis for Java
> Issue Type: Bug
> Components: SQL Maps
> Affects Versions: 2.1.6
> Environment: Win XP, JBoss 4
> Reporter: raja chawat
>
> How do we add per-resultMap uniqueKeys? I don't see any example.
> Please help.
> My resultset is like:
> I have a list of instructors in a group, and every instructor can teach a
> list of courses. My problem is an instructor can belong to multiple groups.
> I see instructor only in 1 group. And I see list of components repeated for
> that instructor for every group that he/she belongs to.
> And if I remove the 2nd groupBy, I see instructor in multiple groups. But in
> each group, it is listed n number of times, where n is the number of courses
> he/she can teach.
> Am I doing something wrong here, please comment. How do I resolve this issue?
> Also, the regionID can be same as groupByID, since I am grouping dynamically.
> I have "select region_id as group_by_id".
> <resultMap id="GroupVOXResultMap" class="GroupVOX" groupBy="groupByID">
> <result property="groupByID" column="group_by_id"/>
> <result property="groupByDesc" column="group_by_desc"/>
> <result property="instructorVOXList"
> resultMap="Scheduler.InstructorVOXResultMap"/>
> </resultMap>
> <resultMap id="InstructorVOXResultMap" class="InstructorVOX"
> groupBy="instructorID">
> <result property="instructorID" column="inst_id"/>
> <result property="firstName" column="fname"/>
> <result property="middleInitial" column="mi"/>
> <result property="lastName" column="lname"/>
> <result property="regionID" column="region_id"/>
> <result property="regionDesc" column="region_desc"/>
> <result property="cpntPKs"
> resultMap="Scheduler.ComponentPKResultMap"/>
> </resultMap>
> <resultMap id="ComponentPKResultMap" class="ComponentPK">
> <result property="componentTypeID" column="cpnt_typ_id"/>
> <result property="componentID" column="cpnt_id"/>
> <result property="revisionDate" column="rev_dte"/>
> </resultMap>
> I found a workaround for this problem. If you add regionID to the groupBy in
> the innerMap, it works. Only thing is both regionID and groupID are same
> columns referenced by different names. It will fail, if you use "groupID" in
> the inner resultmap.
> Is this a bug? Do the keys in the groupBy have to be unique?
> <resultMap id="GroupVOXResultMap" class="GroupVOX" groupBy="groupByID">
> <result property="groupByID" column="group_by_id"/>
> <result property="groupByDesc" column="group_by_desc"/>
> <result property="instructorVOXList"
> resultMap="Scheduler.InstructorVOXResultMap"/>
> </resultMap>
> <resultMap id="InstructorVOXResultMap" class="InstructorVOX"
> groupBy="regionID, instructorID">
> <result property="instructorID" column="inst_id"/>
> <result property="firstName" column="fname"/>
> <result property="middleInitial" column="mi"/>
> <result property="lastName" column="lname"/>
> <result property="regionID" column="region_id"/>
> <result property="regionDesc" column="region_desc"/>
> <result property="cpntPKs"
> resultMap="Scheduler.ComponentPKResultMap"/>
> </resultMap>
> <resultMap id="ComponentPKResultMap" class="ComponentPK">
> <result property="componentTypeID" column="cpnt_typ_id"/>
> <result property="componentID" column="cpnt_id"/>
> <result property="revisionDate" column="rev_dte"/>
> </resultMap>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.