ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexis Pigeon <pigeon.ale...@gmail.com>
Subject Re: Serious Problem with Select resultClass=HashMap on different tables
Date Thu, 07 Jan 2010 11:27:18 GMT
Hi starfish0r,

Assuming you are using iBATIS 2 (I have no clue if this has been kept in
iBATIS 3 too), what you are looking for is the "remapResults" attribute in
the select tag.
>From the documentation:

"Since the overhead to introspect/determine the resultset metadata is not
trivial, iBATIS will remember what
was returned the last time the query was run. This creates problems in
situations similar to the examples
above, hence the possibility to do metadata introspection with every query
So if the return columns can change set remapResults to true, else set
remapResults to false to avoid the
overhead of metadata introspection."


2010/1/7 starfish0r <starfish0r@gmail.com>

> Hey everyone,
> I've been working with iBatis for a year now and so far it's been
> incredible.
> I am working with many different tables and created a web app to
> dynamically
> view data from any table.
> Of course in this case i cannot work with a table-specific class as a
> resultClass due to different table columns/column names.
> The solution was to use one select statement with resultClass=HashMap.
> Unfortunately, iBatis internally remembers which columns a query returns.
> (Found out about that by stepping through iBatis' sources at runtime)
> When i switch to viewing another table, the select fails, because the
> statement does not retrieve values for the 'remembered' columns.
> Query:
> <select id="dynamicSelect" parameterClass="java.util.HashMap"
> resultClass="java.util.HashMap">
>    SELECT * FROM $table$ WHERE $prefix$_used_flag = 1
> </select>
> As u can see, i provide which table to get the data from.
> I select data from the first table, which contains the column 'ptt_id'.
> When i call the same query on a different table, the query fails:
> com.ibatis.common.jdbc.exception.NestedSQLException:
> --- The error occurred in maps/mapFormTable.xml.
> --- The error occurred while applying a result map.
> --- Check the FormTable.dynamicSelect-AutoResultMap.
> --- Check the result mapping for the 'ptt_id' property.
> --- Cause: java.sql.SQLException: Column 'ptt_id' not found.
> How do i fix this? The application heavily relies on that functionality.
> The 'remembering' map is not accessible, so i cannot modify iBatis'
> expectations regarding the result HashMap.
> I have tried capsulating the queries in their own transaction, session and
> both.
> Nothing works...
> Help would be highly appreciated!
> --
> View this message in context:
> http://old.nabble.com/Serious-Problem-with-Select-resultClass%3DHashMap-on-different-tables-tp27058010p27058010.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org

View raw message