-
Mybatis动态代理的好处
传统分层模式,我们在处理业务的时候需要些 dao 层,然后再 写 dao层的实现类
具体处理业务在 dao 层的实现类中进行处理, 而 mybatis 在配置 实体类的 Mapper文件之后, 只需要写 相当于 dao(Maper接口) 层接口 , mybatis 就会自动生成 dao (Mapper接口) 的实现类,就可以 调用 dao(Mapper实现类) 的接口了 -
先来温习一下非动态代理的Mybatis操作:如果有疑问,请看上一篇mybatis的基本入门
- 数据库的实体bean类,`
package com.puya.mybatis.pojo;
import java.io.Serializable;
public class User implements Serializable {
private Integer id;
private String name;
private String station;
private String telephone;
private String address;
private String decidedzone_id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStation() {
return station;
}
public void setStation(String station) {
this.station = station;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getDecidedzone_id() {
return decidedzone_id;
}
public void setDecidedzone_id(String decidedzone_id) {
this.decidedzone_id = decidedzone_id;
}
@Override
public String toString() {
return "User [id=" + id + ", name=" + name + ", station=" + station + ", telephone=" + telephone + ", address="
+ address + ", decidedzone_