<?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="itheima.UserMapper">
<!-- 数据库字段和实体类的属性明名称不一样 则不能自动封装
解决方法 :1 取别名 数据库字段名 as 对应实体类属性名
2 设置sql片段
3 设置resulMap 将数的列名与实体类的属性名进行匹配(很重要)
-->
<select id="selectAll" resultType="pojo.DishEnpty">
select * from dish;
</select>
<select id="selectName" resultType="pojo.DishEnpty">
select * from dish where name=#{name};
</select>
<!--多条件查询-->
<select id="selectone" resultType="pojo.DishEnpty">
select * from dish
<where>
<if test="type!=null and type !=''">
type=#{type}
</if>
<if test="name!=null and name!=''">
and name like #{name}
</if>
</where>
<!--但条件查询-->
</select>
<select id="selectSingle" resultType="pojo.DishEnpty">
select *from dish
<where>
<choose>
<when test="type!=null and type !=''">
type=#{type}
</when>
<when test="name!=null and name!=''">
name like #{name}
</when>
</choose>
</where>
</select>
</mapper>