Welcome to 16892 Developer Community-Open, Learning,Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

拿来一份别人的xml 映射文件是这样的

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.imooc.user.mapper.FansMapper">
  <resultMap id="BaseResultMap" type="com.imooc.pojo.Fans">

    <id column="id" jdbcType="VARCHAR" property="id" />
    <result column="writer_id" jdbcType="VARCHAR" property="writerId" />
    <result column="fan_id" jdbcType="VARCHAR" property="fanId" />
    <result column="face" jdbcType="VARCHAR" property="face" />
    <result column="fan_nickname" jdbcType="VARCHAR" property="fanNickname" />
    <result column="sex" jdbcType="INTEGER" property="sex" />
    <result column="province" jdbcType="VARCHAR" property="province" />
  </resultMap>
</mapper>

打开
https://mybatis.org/mybatis-3...
官方文档

咦! mapper 这么没有哦! 他是什么意思呀???
id id 这个也么有哦

result又是什么鬼。。。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

结果映射这一块,有个示例代码和你的这个基本相同。

<resultMap id="userResultMap" type="User">
  <id property="id" column="user_id" />
  <result property="username" column="user_name"/>
  <result property="password" column="hashed_password"/>
</resultMap>

id & result下面也都是有的

<id property="id" column="post_id"/>
<result property="subject" column="post_subject"/>

我猜让你感到恼火的主要原因有以下几点:

  1. 对Mybatis不熟悉;
  2. 官方文档用词生硬看不懂;

那咋办呢,我有以下解决方案:

方法一:
从你这namespace可以看出来,这应该是imooc的相关课程教程,可以去imooc平台查找相关课程教程,比如:MyBatis 入门教程

方法二:
官方文档看不懂可以看别人写的博客呀,打开搜索引擎,关键词“Mybatis xml mapper”,立马就能找到一堆博客,如:MyBatis mapper.xml 详解


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to 16892 Developer Community-Open, Learning and Share
...