Demo Sqlmap configuration file, through the use of ' $ ' and ' * ' to achieve dynamic mapping table to a map role XML version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE sqlmap Public "-//ibatis.com//dtd SQL Map 2.0//en" "Http://www.ibatis.com/dtd/sql-map-2.dtd" >
< SELECT id = "Useautoresultmapexample" Parameterclass = "Map" >
Use $dbName $
select* from $tableName $
</Select >
</Sqlmap >
That is to configure a statment inside the Ibatis to execute multiple queries, taking full advantage of the map mapping features.
To execute multiple queries.
Like what
SELECT * FROM Myexample
SELECT * FROM MyWork
Using "*" and not using ResultClass to specify return
But in the default configuration, at the time of use
More than 2 times passed in different $dbname$, $tabeName $ call this useautoresultmapexample,
I'm going to report java.sql.SQLException:Invalid column name error
Because Ibatis own Autoresultmap cache, although you pass in the $tablename$ different, but he always
With the first set of Autoresultmap cache to match the $tablename$ of course there are mistakes
Workaround: Use multiple statment or use remapresults= "true" (for efficiency he defaults to false)
above because of efficiency problems, we recommend or use multiple statement map to different model above, It is not recommended that production systems be used in this way.