ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeff Butler" <jeffgbut...@gmail.com>
Subject Re: Table alias in results map.
Date Wed, 29 Mar 2006 21:02:42 GMT
Short answer - no.

Only the column name is returned in the result set.  This is JDBC, not just
iBATIS.  Run the query in something like the Squirrel SQL client to verify.

A better solution would be to use a real domain object instead of a map, and
use iBATIS' group by and descriminator support.

Jeff Butler


On 3/29/06, Daniel Pitts <Daniel.Pitts@cnet.com> wrote:
>
> I want to perform a query like:
> <select id="getData" resultClass="map" parameterClass="string">
> Select * FROM data AS `root:data` JOIN other AS `root:other` JOIN
> something as `root:other:something` WHERE $where$
> </select>
>
> The tables "data", "other", and "something" may or may not have
> similarly named columns.  The aliases correspond to bean's in a map.
> ---CODE---
> Map myQuery = new HashMap();
> myQuery.put("root:data" = new DataBean());
> myQuery.put("root:other" = new OtherBean());
> myQuery.put("root:other:something" = new SomethingBean());
>
> sqlMap.queryForObject("getData", where, myQuery);
> ----------
>
> Unfortunately, ibatis seems to look only at the column name, not the
> table name.  I would use result maps, but the query is way to dynamic.
>
> My current kludge aliases EVERY column. This works, but is a somewhat
> painful hack of introspection, and may be a performance bottleneck.
>
> Is there any way to tell ibatis to use the table names as part of the
> result map?
>
> Much thanks in advance.
> Daniel.
>

Mime
View raw message