有四个分别是select insert delete update
这个是查询 他的ID对应的是Dao层的方法名 他的resultMap对应的是resultMap的名字
<select id="getall" resultMap="maop">
SELECT *
from Merch
<where>
1=1
<if test="page != null and rows != null">
limit #{page},#{rows}
</if>
</where>
</select>
这个是添加
<insert id="add">
INSERT INTO merch(`Code`,`Name`,Factory,Package,Price) VALUE(#{Code},#{Name},#{Factory},#{Package},#{Price})
</insert>
这个是删除
<delete id="delete">
delete from merch where Code=#{Code}
</delete>
这个是修改
<update id="update">
update merch SET `Name`=#{Name},Factory=#{Factory},Package=#{Package},Price=#{Price} where `Code`=#{Code}
</update>
这里是整个Mapper页面
<?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.fty.mapper.MerchMapper">
<resultMap type="com.fty.entity.Merch" id="maop">
<id column="Code" property="Code" jdbcType="VARCHAR" />
<result column="Name" property="Name" jdbcType="VARCHAR" />
<result column="Factory" property="Factory" jdbcType="VARCHAR" />
<result column="Package" property="Package" jdbcType="VARCHAR" />
<result column="Price" property="Price" jdbcType="DECIMAL" />
</resultMap>
<sql id="Base_Column_List" >
Code,Name,Factory,Package,Price
</sql>
<select id="getall" resultMap="maop">
SELECT *
from Merch
<where>
1=1
<if test="page != null and rows != null">
limit #{page},#{rows}
</if>
</where>
</select>
<select id="getcount" resultType="int">
SELECT count(*) from Merch
</select>
<insert id="add">
INSERT INTO merch(`Code`,`Name`,Factory,Package,Price) VALUE(#{Code},#{Name},#{Factory},#{Package},#{Price})
</insert>
<delete id="delete">
delete from merch where Code=#{Code}
</delete>
<update id="update">
update merch SET `Name`=#{Name},Factory=#{Factory},Package=#{Package},Price=#{Price} where `Code`=#{Code}
</update>
<select id="getMerchAll" resultMap="maop">
SELECT *
from Merch
</select>
<select id="getMerchGetAll" resultMap="maop">
SELECT *
from Merch
</select>
</mapper>
可以留个邮箱我给你发源码 或者加我QQ1052678420也能发