您好,登錄后才能下訂單哦!
應用場景設置
以學生的信息管理系統為例,演示學生信息的增刪改查。這里定義學生的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() {
}
}
并且定義了學生的增刪改查接口如下:
IStudentDao.java
public interface IStudentDao {
void insert(Student s);
void update(Student s);
void delete(String studentId);
}
操縱MongoDB的接口實現文件如下,
IStudentDaoImpl.java
public class IStudentDaoImpl implements IStudentDao{
@Override
public void insert(Student s) {
//暫未實現
}
@Override
public void update(Student s) {
//暫未實現
}
@Override
public void delete(String studentId) {
//暫未實現
}
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。