ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larry Meadors" <lmead...@apache.org>
Subject Re: Problem executing dynamic SQL statement
Date Fri, 26 Oct 2007 14:02:26 GMT
Add remapResults="true" to your select element.

Larry


On 10/26/07, Dave.Derry@equifax.com <Dave.Derry@equifax.com> wrote:
>
> I'm having a problem with a dynamic statement. It is executed against
> different tables that have different structures. But it seems that the
> columns for the first execution are being cached somehow. The statement is
> this:
>
> <select id="getScoreCounts" parameterClass="map" resultClass=
> "java.util.HashMap">
>       select      * from
>       <dynamic>
>       <iterate open="(" close=")" conjunction="),(" property="scoreCodes">
>             select count($scoreCodes[]$) as $scoreCodes[]$
>             from $tableName$
>             where $scoreCodes[]$ is not null and record_type = #recordType#
>       </iterate>
>       </dynamic>
> </select>
>
> The result is the same without the <dynamic> tag. The logged statement
> looks correct, but the SQL error references a column from a previous
> execution.
>
> For example, in the logs I'll see something like
>
> select * from      (    select count(COL_A) as COL_A from TABLE_X where
> COL_A is not null and record_type = ?   ),(    select count(COL_B) as COL_B
> from TABLE_A where COL_B is not null and record_type = ?   )
>
> this statemnet will succeed. then I'll see something like
>
> select * from      (    select count(COL_A) as COL_A from TABLE_YY where
> COL_A is not null and record_type = ?   )
>
> and that will cause a SQL error:
>
> check the result mapping for the 'COL_B' property.
> Cause: java.sql.SQLException: Invalid column name
>
>
> Since there is no 'COL_B' in that statement, this is causing me a lot of
> grief; I would sure appreciate some insight on this.
>
> BTW I'm using version 2.3.0.677, with Spring 2.0.4
>
> Thanks,
> Dave Derry
>
> We must begin not just to act, but to think, for there is no better slave
> than the one who believes his slavery to be freedom, and we are in
> no greater peril than when we cannot see the chains on our minds
> because there are yet no chains on our feet.
> -- Michael Reid
>
>
> This message contains information from Equifax Inc. which may be
> confidential and privileged.  If you are not an intended recipient, please
> refrain from any disclosure, copying, distribution or use of this
> information and note that such actions are prohibited.  If you have
> received this transmission in error, please notify by e-mail
> postmaster@equifax.com.
>
>
>

Mime
View raw message