在前一篇文章中,我们使用mvn clean compile后发现编译器在指定的路径下自动生成了很多文件,这些文件究竟各自有什么作用呢?
generator/tables/daos
daos文件下下存放编译自动生成的数据表所对应的dao层的类,并且该类中根据数据表的字段定义了常用的查询操作的方法。
上图中代码可以很轻易的发现实现了根据ID查询一个、或者多个数据,根据firstname查询多个数据的功能。
generator/tables/pojos
pojos文件下存放着编译生成的数据表对应的标准的pojo类。
public class Users implements Serializable {
private static final long serialVersionUID = -926895054;
private Integer id;
private String firstname;
private String gender;
private String province;
private String city;
private String phonenumber;
private String secondname;
private Integer age;
public Users() {}
public Users(Users value) {
this.id = value.id;
this.firstname = value.firstname;
this.gender = value.gender;
this.province = value.province;
this.city = value.city;
this.phonenumber = value.phonenumber;
this.secondname = value.secondname;
this.age = value.age;
}
public Users(
Integer id,
String firstname,
String gender,
String province,
String city,
String phonenumber,
String secondname,
Integer age
) {
this.id = id;
this.firstname = firstname;
this.gender = gender;
this.province = province;
this.city = city;
this.phonenumber = phonenumber;
this.secondname = secondname;
this.age = age;
}
public Integer getId() {
return this.id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFirstname() {
return this.firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getGender() {
return this.gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getProvince() {
return this.province;
}
public void setProvince(String province) {
this.province = province;
}
public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;
}
public String getPhonenumber() {
return this.phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
public String getSecondname() {
return this.secondname;
}
public void setSecondname(String secondname) {
this.secondname = secondname;
}
public Integer getAge() {
return this.