You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Daniel Pitts <Da...@cnet.com> on 2006/03/24 00:29:44 UTC
Dynamic query woes.
I have a very generic query which has different column names, depending
on what was passed to it.
<select id="query" resultClass="java.util.HashMap" parameterClass="map">
SELECT $columns$ FROM $from$ WHERE $where$
</select>
It works fine the first time. And it even works fine if $columns$
doesn't change. However, if $columns$ had (for instance) "my_column" in
one query, but then it had "another_column" in a later query, the last
query fail with "no such column 'my_column'"
Is this a bug, or a feature? Also, is there a work-around?
Thanks.
Re: Dynamic query woes.
Posted by Ted Schrader <ts...@gmail.com>.
Here are some juicy details on the remapResults attribute:
http://opensource2.atlassian.com/confluence/oss/pages/viewpage.action?pageId=3057
Ted
Re: Dynamic query woes.
Posted by Larry Meadors <lm...@apache.org>.
Add remapResults="true" in the select tag.
There is a performance hit, but it will work.
Larry
On 3/23/06, Daniel Pitts <Da...@cnet.com> wrote:
> I have a very generic query which has different column names, depending
> on what was passed to it.
> <select id="query" resultClass="java.util.HashMap" parameterClass="map">
> SELECT $columns$ FROM $from$ WHERE $where$
> </select>
>
> It works fine the first time. And it even works fine if $columns$
> doesn't change. However, if $columns$ had (for instance) "my_column" in
> one query, but then it had "another_column" in a later query, the last
> query fail with "no such column 'my_column'"
>
> Is this a bug, or a feature? Also, is there a work-around?
> Thanks.
>