應(yīng)用場(chǎng)景設(shè)置
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、成都小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了黃岡免費(fèi)建站歡迎大家使用!
以學(xué)生的信息管理系統(tǒng)為例,演示學(xué)生信息的增刪改查。這里定義學(xué)生的Bean類為:
Student.java
public class Student {
private String studentId;
private String name;
private int weight;
private int height;
private Date birthday;
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
@Override
public String toString() {
return "Student [studentId=" + studentId + ", name=" + name
+ ", weight=" + weight + ", height=" + height + ", birthday="
+ birthday + "]";
}
public Student(String studentId, String name, int weight, int height,
Date birthday) {
super();
this.studentId = studentId;
this.name = name;
this.weight = weight;
this.height = height;
this.birthday = birthday;
}
public Student() {
}
}
并且定義了學(xué)生的增刪改查接口如下:
IStudentDao.java
public interface IStudentDao {
void insert(Student s);
void update(Student s);
void delete(String studentId);
}
操縱MongoDB的接口實(shí)現(xiàn)文件如下,
IStudentDaoImpl.java
public class IStudentDaoImpl implements IStudentDao{
@Override
public void insert(Student s) {
//暫未實(shí)現(xiàn)
}
@Override
public void update(Student s) {
//暫未實(shí)現(xiàn)
}
@Override
public void delete(String studentId) {
//暫未實(shí)現(xiàn)
}
}