起初我以为上述二者必须一致,后来发现也是可以像Hibernate那样在xml文件中进行映射的。
<mapper namespace="com.tenghu.mybatis.model.xml.DepartmentMapper"> <!-- 配置映射字段 --> <resultMap type="Department" id="tab_department"> <id property="ids" column="ids"/> <result property="deName" column="de_name"/> <result property="pIds" column="p_ids"/> <result property="deChargePerson" column="de_charge_person"/> <result property="createTime" column="create_time"/> </resultMap> <!-- 查询所有部门 --> <select id="queryAllDepartment" resultMap="tab_department"> select * from tab_department </select> </mapper>