1,数据库表为(员工<主键id,员工姓名name>,部门<主键id,外键em_id,部门department,职位post>);
2,实现按员工姓名查询,得出所属部门和职位
3,按部门查询,得出该部门所有的人员
怪我咯2017-04-17 17:36:40
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< ;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.