<?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"><!--namespace:名称空间数据库的字段名称 和 实体类的属性名称 不一样 则不能自动封装数据* 方法: 1.起别名 : 用as ,对不一样的列明起别名,让别名和列明相同 2.resultMap:完成不一样的属性名和列名的映射 1.定义<resultMap>标签 2.在<select>标签中,使用resultMap属性替换resultType属性?-->?<mapper namespace="com.wfy.mapper.BrandMapper">? <resultMap id="brandResultMap" type="brand"> <result property="brandName" column="brand_name"/> <result property="companyName" column="company_name"/> </resultMap>?? <delete id="DeleteByIds"> delete from brand where id in <foreach collection="ids" item="id" open="(" separator="," close=")"> #{id} </foreach> </delete><!-- where brand_name=#{brand.brandName}--> <select id="SelectByPageAndCondition" resultMap="brandResultMap"> select * from brand <where> <if test="brand.brandName !=null and brand.brandName!=''"> and brand_name like #{brand.brandName} </if> <if test="brand.companyName !=null and brand.companyName!=''"> and company_name like #{brand.companyName} </if> <if test="brand.status !=null"> and status=#{brand.status} </if> </where>? limit #{begin} ,#{size}? </select> <select id="SelectTotalCountByCondition" resultType="java.lang.Integer"> select count(*) from brand <where> <if test="brandName !=null and brandName!=''"> and brand_name like #{brandName} </if> <if test="companyName !=null and companyName!=''"> and company_name like #{companyName} </if> <if test="status !=null"> and status=#{status} </if> </where>??</select>??</mapper>
注意这里的映射文件需要在resource目录下创建分层目录,通过‘\’进行分割
及文件的目录名为:“ com\wfy\mapper”
- Service层(业务逻辑层)
 
- 创建BrandService接口
 
经验总结扩展阅读
- 含具体案例 Java8新特性之Stream流
- 电影爱人完整剧情介绍?
- 会话跟踪技术 - Cookie 和 Session 快速上手 + 登陆注册案例
- 案例分享-https证书链不完整导致请求失败
- 不明原因不孕怎么办啊
- JavaWeb505错误,IDEA版问题解决
- 一 CPS攻击案例——基于脉冲宽度调制PWM的无人机攻击
- 黑蒜的制作方法
- 教育案例怎么写
- 大鱼歌词完整版

 
   
   
   
   
   
   
   
   
   
  