Ibatis autoresultmap Default configuration problems that occur when using

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.