MyBatis queries are mapped, the return value type can use Resulttype and resultmap can also be used. The former refers to the direct return value type, usually the domain name, of course, here can write all the path of domain can also be abbreviated so that you have to scan the entity in the MyBatis configuration file. While the latter represents a reference to an external resultmap, both cannot exist at the same time.
MyBatis in the query mapping, in fact, and JdbcTemplate in the same queryforlist is the query out of each attribute is placed in a corresponding map, where the key is the property name, the value is the corresponding value.
When we provide a return type of Resulttype, MyBatis will remove the key value pair from the map to the property assigned to the object specified by Resulttype, so the return type of each query map MyBatis is resultmap. Just when the return type we provide is Resulttype, MyBatis automatically assigns the corresponding value to the property of the object specified by Resulttype.
When the return type we provide is resultmap, because map does not represent the domain model well, we need to define our own mapping of the Resultmap and domain model to further convert it to the corresponding object.
<!--Seckill Querybyid (long seckillid);-->
<select id= "Querybyid" parametertype= "Long" resulttype= "Seckill" >
Select Seckill_id,name,number,start_time,end_time,create_time
From Seckill
where seckill_id = #{seckillid}
</select>
MyBatis automatically creates a Resultmap object because Resulttype is specified here, so it is removed from the Resultmap and assigned to the corresponding key value in the Seckill object.
Follow-up introduction then write ~ work
Resulttype and Resultmap in the MyBatis