Mybatis -- resulttype and resultmap

Source: Internet
Author: User


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

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.