ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: duplicate column names
Date Wed, 11 Oct 2006 02:56:53 GMT
No.

This would be a impossible solution.  We can't arbitrairly map two columns
with the same name, unless you wanted to do it by column number.  But that
is also arbitrary with SELECT *.

I'm afraid you're asking for the impossible.  I suggest you use aliases.

Clinton

On 10/10/06, Maarten Bosteels <mbosteels.dns@gmail.com> wrote:
>
> Hello,
>
> I found this example in the Developer Guide::
>
> <resultMap id="get-product-result" class="com.ibatis.example.Product">
> <result property="id" column="PRD_ID"/>
> <result property="description" column="PRD_DESCRIPTION"/>
> <result property="category" resultMap="get-category-result" />
> </resultMap>
>
> <resultMap id="get-category-result" class="com.ibatis.example.Category">
> <result property="id" column="CAT_ID" />
> <result property="description" column="CAT_DESCRIPTION" />
> </resultMap>
>
> <select id="getProduct" parameterClass="int"
> resultMap="get-product-result">
> select *
> from PRODUCT, CATEGORY
> where PRD_CAT_ID=CAT_ID
> and PRD_ID = #value#
> </select>
>
> What if the columns in PRODUCT and CATEGORY do not have the PRD_ and CAT_
> prefixes and share column-names (eg ID) ?
> It would most probably work to have a column alias for every column
> but I would like to avoid that and stick with the star in "select *
> from"
>
> I am having a similar problem with RowMapper and Spring's JDBCTemplate
> and wondered if iBatis has a solution.
>
> Thanks, I hope my question is clear.
>
> Maarten
>

Mime
View raw message