1.单个关联查询association
1.1实体之间的关联表示
package com.worldly.config.entity;
import java.io.Serializable;
/**
* @Description
* @Author xiaoqx <worldly_xuan@163.com>
* @Version V1.0.0
* @Since 2017/11/26
*/
public class Employee implements Serializable {
private Integer id;
private String name;
private String email;
private String tel;
private Department dep;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public Department getDep() {
return dep;
}
public void setDep(Department dep) {
this.dep = dep;
}
@Override
public String toString() {
return "{\"Employee\":{"
+ "\"id\":\"" + id + "\""
+ ", \"name\":\"" + name + "\""
+ ", \"email\":\"" + email + "\""
+ ", \"tel\":\"" + tel + "\""
+ ", \"dep\":" + dep
+ "}}";
}
}
1.2 两种关联查询方式
//第一中方式:直接进行关联查询把关联实体的属性在xml中配置
//然后关联查出来
<resultMap id="emp2ResultMap" type="com.worldly.config.entity.Employee">
<id column="emp_id" property="id"></id>
<result column="emp_name" property="name"/>
<result column="emp_email" property="email"/>
<result column="emp_tel"