SQL mapping file for MyBatis (iv)

Source: Internet
Author: User

Mapper-namespace
Cache-Configure caching for a given namespace
cache-ref– referencing cache configuration from other namespaces
resultmap– used to describe the correspondence between a database result set and an object
sql– SQL blocks that can be reused, or can be referenced by other statements
insert– Mapping INSERT statement
update– Map UPDATE statement
delete– Map Delete statements
select– Mapping Query statements

First, the result set resulttype= "HashMap"    

can solve multi-table joint Check, note: generics are map benefit: Do not define RESULTMAP tags

If an object is used as a property of another object, you can use the Resultmap property

Second, the use of Resultmap

Description of the Resultmap in XML

  

Auto Fill for properties

  

mapping files

    • Resulttype: Direct representation of return type
    • Basic data types
    • Complex data types
    • Resultmap: References to external Resultmap
    • Application Scenarios:
    • Database field information is inconsistent with object properties
    • Complex federated queries, free control of map results
    • Both cannot exist at the same time and are essentially map data structures

  Third, the setting of Resultmap auto-mapping

Resultmap Automatic Mapping matching prerequisites: Field names are consistent with attribute names
Automatic mapping level for Resultmap-automappingbehavior
PARTIAL (default): Automatically matches all
<settings>
<setting name= "Automappingbehavior" value= "NONE"/>
</settings>

SQL mapping file for MyBatis (iv)

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.