用户和职位
1、用户
package com.qf.meeting.pojo;
import java.io.Serializable;
import java.util.Set;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
public class User implements Serializable{
private final static Logger LOG = LogManager.getLogger(User.class);
private Integer userId;
private String userLoginName;
private String userTel;
private String userPwd;
private String photo;
private String userName;
private Delegation delegation;
private Set<Staff> staffs;
public User() {
super();
}
@Override
public String toString() {
return "User [userId=" + userId + ", userLoginName=" + userLoginName + ", userTel=" + userTel + ", userPwd="
+ userPwd + ", photo=" + photo + ", userName=" + userName + ", delegation=" + delegation + ", staffs="
+ staffs + "]";
}
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserLoginName() {
return userLoginName;
}
public void setUserLoginName(String userLoginName) {
this.userLoginName = userLoginName;
}
public String getUserTel() {
return userTel;
}
public void setUserTel(String userTel) {
this.userTel = userTel;
}
public String getUserPwd() {
return userPwd;
}
public void setUserPwd(String userPwd) {
this.userPwd = userPwd;
}
public String getPhoto() {
return photo;
}
public void setPhoto(String photo) {
this.photo = photo;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Delegation getDelegation() {
return delegation;
}
public void setDelegation(Delegation delegation) {
this.delegation = delegation;
}
public Set<Staff> getStaffs() {
return staffs;
}
public void setStaffs(Set<Staff> staffs) {
this.staffs = staffs;
}
public User(Integer userId, String userLoginName, String userTel, String userPwd, String photo, String userName,
Delegation delegation, Set<Staff> staffs) {
super();
this.userId = userId;
this.userLoginName = userLoginName;
this.userTel = userTel;
this.userPwd = userPwd;
this.photo = photo;
this.userName = userName;
this.delegation = delegation;
this.staffs = staffs;
}
}
2、职位
package com.qf.meeting.pojo;
import java.io.Serializable;
import java.util.Set;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
public class Staff implements Serializable{
private final static Logger LOG = LogManager.getLogger(Staff.class);
private Integer staffId;
private String staffName;
private Set<User> user;
public Staff() {
super();
}
public Staff(Integer staffId, String staffName, Set<User> user) {
super();
this.staffId = staffId;
this.staffName = staffName;
this.user = user;
}
@Override
public String toString() {
return "Staff [staffId=" + staffId + ", staffName=" + staffName + ", user=" + user + "]";
}
public Integer getStaffId() {
return staffId;
}
public void setStaffId(Integer staffId) {
this.staffId = staffId;
}
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public Set<User> getUser() {
return user;
}
public void setUser(Set<User> user) {
this.user = user;
}
}
3、xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.qf.meeting.mapper.UserMapper">
<resultMap type="com.qf.meeting.pojo.User" id="UserAndStaff">
<id property="userId" column="userId" />
<result property="userLoginName" column="userLoginName" />
<result property="userTel" column="userTel" />
<result property="userPwd" column="userPwd" />
<result property="photo" column="photo" />
<result property="userName" column="userName" />
<collection property="staffs" ofType="com.qf.meeting.pojo.Staff" autoMapping="true">
<id property="staffId" column="staffId"/>
<result property="staffName" column="staffName"/>
</collection>
</resultMap>
<select id="findAllUser1" resultMap="UserAndStaff" >
select * from t_user u ,t_staff s ,t_user_staff t1 where u.userId = t1.userId and s.staffId = t1.staffId ;
</select>
</mapper>