<?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="ssm.mapper.StudentMapper" >
<resultMap id="BaseResultMap" type="ssm.pojo.Student" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="birthday" property="birthday" jdbcType="DATE" />
<result column="cid" property="cid" jdbcType="INTEGER" />
<result column="favorite" property="favorite" jdbcType="VARCHAR" />
<result column="picture" property="picture" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, birthday, cid, favorite, picture
</sql>
<!-- 带分页的列表 -->
<select id="selectPaging" parameterType="ssm.pojo.PageInfo" resultMap="BaseResultMap">
select * from student
<where>
<if test="keyWord.firstCondition != null and keyWord.firstCondition != '' " >
name like "%${keyWord.firstCondition}%"
</if>
<if test="keyWord.secondCondition != null and keyWord.secondCondition != '' " >
and favorite= #{keyWord.secondCondition}
</if>
<if test="keyWord.thirdCondition != null and keyWord.thirdCondition != '' " >
and cid= #{keyWord.thirdCondition}
</if>
<if test="keyWord.fourthCondition != null and keyWord.fourthCondition != '' " >
and name= #{keyWord.fourthCondition}
</if>
</where>
limit #{pageRow},#{pageSize}
</select>
<!-- 获取数据总数 -->
<select id="getSum" resultType="java.lang.Integer" parameterType="ssm.pojo.PageInfo">
select count(*) from student
<where>
<if test="keyWord.firstCondition != null and keyWord.firstCondition != '' " >
name like "%${keyWord.firstCondition}%"
</if>
<if test="keyWord.secondCondition != null and keyWord.secondCondition != '' " >
and favorite= #{keyWord.secondCondition}
</if>
<if test="keyWord.thirdCondition != null and keyWord.thirdCondition != '' " >
and cid= #{keyWord.thirdCondition}
</if>
<if test="keyWord.fourthCondition != null and keyWord.fourthCondition != '' " >
and name= #{keyWord.fourthCondition}
</if>
</where>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from student
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from student
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="ssm.pojo.Student" >
insert into student (id, name, birthday,
cid, favorite, picture
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE},
#{cid,jdbcType=INTEGER}, #{favorite,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="ssm.pojo.Student" >
insert into student
<trim prefix="(" suffix=")" suffixOverrides="," >
<!-- <if test="id != null" >
id,
</if> -->
id,
<if test="name != null" >
name,
</if>
<if test="birthday != null" >
birthday,
</if>
<if test="cid != null" >
cid,
</if>
<if test="favorite != null" >
favorite,
</if>
<if test="picture != null" >
picture,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<!-- <if test="id != null" >
#{id,jdbcType=INTEGER},
</if> -->
null,
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
#{birthday,jdbcType=DATE},
</if>
<if test="cid != null" >
#{cid,jdbcType=INTEGER},
</if>
<if test="favorite != null" >
#{favorite,jdbcType=VARCHAR},
</if>
<if test="picture != null" >
#{picture,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="ssm.pojo.Student" >
update student
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
birthday = #{birthday,jdbcType=DATE},
</if>
<if test="cid != null" >
cid = #{cid,jdbcType=INTEGER},
</if>
<if test="favorite != null" >
favorite = #{favorite,jdbcType=VARCHAR},
</if>
<if test="picture != null" >
picture = #{picture,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="ssm.pojo.Student" >
update student
set name = #{name,jdbcType=VARCHAR},
birthday = #{birthday,jdbcType=DATE},
cid = #{cid,jdbcType=INTEGER},
favorite = #{favorite,jdbcType=VARCHAR},
picture = #{picture,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="ssm.mapper.StudentMapper" >
<resultMap id="BaseResultMap" type="ssm.pojo.Student" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="birthday" property="birthday" jdbcType="DATE" />
<result column="cid" property="cid" jdbcType="INTEGER" />
<result column="favorite" property="favorite" jdbcType="VARCHAR" />
<result column="picture" property="picture" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, birthday, cid, favorite, picture
</sql>
<!-- 带分页的列表 -->
<select id="selectPaging" parameterType="ssm.pojo.PageInfo" resultMap="BaseResultMap">
select * from student
<where>
<if test="keyWord.firstCondition != null and keyWord.firstCondition != '' " >
name like "%${keyWord.firstCondition}%"
</if>
<if test="keyWord.secondCondition != null and keyWord.secondCondition != '' " >
and favorite= #{keyWord.secondCondition}
</if>
<if test="keyWord.thirdCondition != null and keyWord.thirdCondition != '' " >
and cid= #{keyWord.thirdCondition}
</if>
<if test="keyWord.fourthCondition != null and keyWord.fourthCondition != '' " >
and name= #{keyWord.fourthCondition}
</if>
</where>
limit #{pageRow},#{pageSize}
</select>
<!-- 获取数据总数 -->
<select id="getSum" resultType="java.lang.Integer" parameterType="ssm.pojo.PageInfo">
select count(*) from student
<where>
<if test="keyWord.firstCondition != null and keyWord.firstCondition != '' " >
name like "%${keyWord.firstCondition}%"
</if>
<if test="keyWord.secondCondition != null and keyWord.secondCondition != '' " >
and favorite= #{keyWord.secondCondition}
</if>
<if test="keyWord.thirdCondition != null and keyWord.thirdCondition != '' " >
and cid= #{keyWord.thirdCondition}
</if>
<if test="keyWord.fourthCondition != null and keyWord.fourthCondition != '' " >
and name= #{keyWord.fourthCondition}
</if>
</where>
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from student
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from student
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="ssm.pojo.Student" >
insert into student (id, name, birthday,
cid, favorite, picture
)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{birthday,jdbcType=DATE},
#{cid,jdbcType=INTEGER}, #{favorite,jdbcType=VARCHAR}, #{picture,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="ssm.pojo.Student" >
insert into student
<trim prefix="(" suffix=")" suffixOverrides="," >
<!-- <if test="id != null" >
id,
</if> -->
id,
<if test="name != null" >
name,
</if>
<if test="birthday != null" >
birthday,
</if>
<if test="cid != null" >
cid,
</if>
<if test="favorite != null" >
favorite,
</if>
<if test="picture != null" >
picture,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<!-- <if test="id != null" >
#{id,jdbcType=INTEGER},
</if> -->
null,
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
#{birthday,jdbcType=DATE},
</if>
<if test="cid != null" >
#{cid,jdbcType=INTEGER},
</if>
<if test="favorite != null" >
#{favorite,jdbcType=VARCHAR},
</if>
<if test="picture != null" >
#{picture,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="ssm.pojo.Student" >
update student
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="birthday != null" >
birthday = #{birthday,jdbcType=DATE},
</if>
<if test="cid != null" >
cid = #{cid,jdbcType=INTEGER},
</if>
<if test="favorite != null" >
favorite = #{favorite,jdbcType=VARCHAR},
</if>
<if test="picture != null" >
picture = #{picture,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="ssm.pojo.Student" >
update student
set name = #{name,jdbcType=VARCHAR},
birthday = #{birthday,jdbcType=DATE},
cid = #{cid,jdbcType=INTEGER},
favorite = #{favorite,jdbcType=VARCHAR},
picture = #{picture,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>