http://opensource.atlassian.com/confluence/oss/display/IBATIS/How+do+I+p ass+in+a+dynamic+table+name+-+or+other+uncommon+parameters
-----Original Message----- From: starfish0r [mailto:starfis...@gmail.com] Sent: Thursday, January 07, 2010 12:19 PM To: user-java@ibatis.apache.org Subject: Serious Problem with Select resultClass=HashMap on different tables 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-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org For additional commands, e-mail: user-java-h...@ibatis.apache.org