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)