Annotation Interface ResultMap


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface ResultMap
The annotation that specify result map names to use.

How to use:
Mapper interface:

 public interface UserMapper {
   @Select("SELECT id, name FROM users WHERE id = #{id}")
   @ResultMap("userMap")
   User selectById(int id);

   @Select("SELECT u.id, u.name FROM users u INNER JOIN users_email ue ON u.id = ue.id WHERE ue.email = #{email}")
   @ResultMap("userMap")
   User selectByEmail(String email);
 }
 
Mapper XML:

 <mapper namespace="com.example.mapper.UserMapper">
   <resultMap id="userMap" type="com.example.model.User">
     <id property="id" column="id" />
     <result property="name" column="name" />
     <association property="email" select="selectUserEmailById" column="id" fetchType="lazy"/>
   </resultMap>
 </mapper>
 
 
Author:
Jeff Butler
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Returns result map names to use.
  • Element Details

    • value

      String[] value
      Returns result map names to use.
      Returns:
      result map names