mysql - jsp+servlet实现多表联合查询,如何建立javabean
巴扎黑
巴扎黑 2017-04-17 17:34:40
0
1
867

1,数据库表为(员工<主键id,员工姓名name>,部门<主键id,外键em_id,部门department,职位post>);
2,实现按员工姓名查询,得出所属部门和职位
3,按部门查询,得出该部门所有的人员

巴扎黑
巴扎黑

reply all(1)
刘奇

First of all, you must determine the relationship between tables;
One-to-many, many-to-one or many-to-many.
Employee employee table Department department table
Then the entity can be created like this:
Class Employee {
private String id;
private String name;
private List&lt ;Department> depts;
}

Class Department {
private String id;
private String post;
private List<Employee> employee;
}
This is the most standard way of writing, If the diagram is simple, you can write all the fields involved into a class;
The next step depends on the SQL statement you write. Are you using mybaits or Hibernate or something else.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template