1 write sql statement ever since aliases
select id, u_name uname, u_age age from emp; u_name will be mapped to the database entity class attributes uname
2 open hump naming MyBatis in the global configuration file can be mapped database underlined camelCase underscore Note that the database must be next to the
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
3 in resultMap Mapper mapping file to customize the advanced mapping
<select id="select01" resultMap="MyMap">
select * from emp where id=#{id}
</select >
<resultMap type="com.atguigu.com.entities.emp" id="MyMap">
<! - mapping the primary key ->
<id column="id" property="id"/>
<! - other columns mapped to the corresponding attribute in the property named entity class ->
<result column="e_name" property="ename"/>
</resultMap>