案例大致文件结构:
BrandMapper接口类,存放有sql的查询方法
pojo下的Brand是实体类
BrandMapper.xml与mybatis-config.xml是配置文件
test包下的myBatisTest是测试类
准备环境1.数据库表tb_Brand
2.实体类 Brand
3.测试用例
4.安装MyBatisX插件
1.数据库表tb_Brand
2.实体类 Brand
package com.itheima.pojo;
public class Brand {
//id主键
private Integer id;
//品牌名称
private String brandName;
//企业名称
private String companyName;
//排序字段
private Integer ordered;
//描述信息
private String discription;
//状态 0:禁用 1:启用
private Integer status;
public Brand(Integer id, String brandName, String companyName, Integer ordered, String discription,
Integer status) {
super();
this.id = id;
this.brandName = brandName;
this.companyName = companyName;
this.ordered = ordered;
this.discription = discription;
this.status = status;
}
public Brand() {
}
@Override
public String toString() {
return "Brand [id=" + id + ", brandName=" + brandName + ", companyName=" + companyName + ", ordered=" + ordered
+ ", discription=" + discription + ", status=" + status + "]";
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getCompanyName() {
return companyName;
}
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
public Integer getOrdered() {
return ordered;
}
public void setOrdered(Integer ordered) {
this.ordered = ordered;
}
public String getDiscription() {
return discription;
}
public void setDiscription(String discription) {
this.discription = discription;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
}
4.安装MyBatisX插件(更好用)
1.查询所有数据(1).编写接口方法Mapper接口 List
参数:无
返回值结果为:List
(2).编写sql语句:sql映射文件



