<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<mapper namespace = "com.introduce.Modle.User2">
<resultMap type="com.introduce.Model.User2" id="user2ResultMap">
<result property="name" column="name" />
<result property="age" column="age" />
<result property="sex" column="sex" />
</resultMap>
<select id="getUser2" resultMap="user2ResultMap">
<![CDATA[select * from User2 where name=#{name}]]>
</select>
</mapper>
只需把<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
这行中的两处config 改成mapper即可
本文介绍了一个具体的MyBatis resultMap配置示例,展示了如何映射数据库字段到Java对象属性,包括name、age和sex等字段的映射,并提供了一个简单的SQL查询语句示例。
1万+





