您好,登錄后才能下訂單哦!
應(yīng)用場景設(shè)置
以學(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的接口實現(xiàn)文件如下,
IStudentDaoImpl.java
public class IStudentDaoImpl implements IStudentDao{
@Override
public void insert(Student s) {
//暫未實現(xiàn)
}
@Override
public void update(Student s) {
//暫未實現(xiàn)
}
@Override
public void delete(String studentId) {
//暫未實現(xiàn)
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。