When querying select ing in mybatis, the return type can be resulttype or resultmap. resulttype indicates the return type directly, while resultmap references the external resultmap, however, the resulttype and resultmap cannot exist at the same time. When mybatis performs query ing, every queried attribute is put in a corresponding map. The key is the attribute name and the value is the corresponding value. When the returned type attribute is resulttype, mybatis extracts the key-value pairs in the map and assigns them to the attributes of the object specified by resulttype. In fact, the returned type of each query ing in mybatis is resultmap, but when the returned type attribute we provide is resulttype, mybatis automatically assigns the corresponding value to the attribute of the object specified by resulttype. When the returned type we provide is resultmap, because map cannot represent the domain model very well, we need to further convert it to the corresponding object, which is often useful in complex queries.
Mybatis -- resulttype and resultmap