You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "raja chawat (JIRA)" <ib...@incubator.apache.org> on 2007/06/21 17:42:26 UTC

[jira] Created: (IBATIS-442) Nested groupBy

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.


[jira] Commented: (IBATIS-442) Nested groupBy

Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
    [ 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.


[jira] Commented: (IBATIS-442) Nested groupBy

Posted by "raja chawat (JIRA)" <ib...@incubator.apache.org>.
    [ https://issues.apache.org/jira/browse/IBATIS-442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12506984 ] 

raja chawat commented on IBATIS-442:
------------------------------------

I thought this is a bug rather than a support request and the other JIRA ticket was not created by me and was already closed when I added comments to it. 

> 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.