You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Tony Ugando (JIRA)" <ib...@incubator.apache.org> on 2007/04/04 20:45:32 UTC

[jira] Created: (IBATIS-415) Obey column order in resultMap

Obey column order in resultMap
------------------------------

                 Key: IBATIS-415
                 URL: https://issues.apache.org/jira/browse/IBATIS-415
             Project: iBatis for Java
          Issue Type: New Feature
          Components: SQL Maps
    Affects Versions: 2.3.1
            Reporter: Tony Ugando


It will be extremely beneficial if iBatis could lookup column names in a resultSet, in the exact same order they are found in the resultMap.  This would allow users to maintain joins much easier, specifically for tables with a lot of columns.  Maybe an attribute can be added to the resultMap tag, named obeyColumnOrder="true/false".  When setting this attribute to true, then the columns will be read in the exact same order that they are found in the resultMap, and any nested or inherited result maps as well.

Currently, it is truly a nightmare when dealing with joined tables that have conflicting column names.  You either need to define an alias for each column name, in each table, which is extremely tedious, or you need to use the columnIndex attribute in the result tag.  The columnIndex solution is also very tedious to maintain, and it requires you to create multiple resultMaps for each table that you are modeling.

eq.
select
TBL_1.*, TBL_2.*
from TBL_1
left outer join TBL_2
on TBL_1.SEQ = TBL_2.FK_SEQ

is much easier to maintain than...

select
TBL_1.SEQ, TBL_1.COL,...,
TBL_2.SEQ, TBL_2.COL,...
from TBL_1
left outer join TBL_2
on TBL_1.SEQ = TBL_2.FK_SEQ



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


[jira] Closed: (IBATIS-415) Obey column order in resultMap

Posted by "Jeff Butler (JIRA)" <ib...@incubator.apache.org>.
     [ https://issues.apache.org/jira/browse/IBATIS-415?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jeff Butler closed IBATIS-415.
------------------------------

    Resolution: Invalid

iBATIS already retrieves columns in the order they are specified in a result map.

As for the issue you raise, there is nothing iBATIS can do.  The JDBC specification explicitly states that if multiple columns have the same name in a result set, then only the first one will be returned when getting by column name.  The only way to ensure that you'll get the proper columns is to use a column index or to rename the columns so that they are unique.

Sorry for the hassle, but blame JDBC - not us :)


> Obey column order in resultMap
> ------------------------------
>
>                 Key: IBATIS-415
>                 URL: https://issues.apache.org/jira/browse/IBATIS-415
>             Project: iBatis for Java
>          Issue Type: New Feature
>          Components: SQL Maps
>    Affects Versions: 2.3.1
>            Reporter: Tony Ugando
>
> It will be extremely beneficial if iBatis could lookup column names in a resultSet, in the exact same order they are found in the resultMap.  This would allow users to maintain joins much easier, specifically for tables with a lot of columns.  Maybe an attribute can be added to the resultMap tag, named obeyColumnOrder="true/false".  When setting this attribute to true, then the columns will be read in the exact same order that they are found in the resultMap, and any nested or inherited result maps as well.
> Currently, it is truly a nightmare when dealing with joined tables that have conflicting column names.  You either need to define an alias for each column name, in each table, which is extremely tedious, or you need to use the columnIndex attribute in the result tag.  The columnIndex solution is also very tedious to maintain, and it requires you to create multiple resultMaps for each table that you are modeling.
> eq.
> select
> TBL_1.*, TBL_2.*
> from TBL_1
> left outer join TBL_2
> on TBL_1.SEQ = TBL_2.FK_SEQ
> is much easier to maintain than...
> select
> TBL_1.SEQ, TBL_1.COL,...,
> TBL_2.SEQ, TBL_2.COL,...
> from TBL_1
> left outer join TBL_2
> on TBL_1.SEQ = TBL_2.FK_SEQ

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