码迷,mamicode.com
首页 > 其他好文 > 详细

连表查询的简单方法!!

时间:2017-07-19 14:24:04      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:value   key   连表   ima   list   lis   sel   eof   source   

在主表(Appointment)里面private+副表的对象

private Department(副表) depa;

private User(副表) u;

然后source set get

再在主表service层里面

@Autowired
private AppointmentMapper appointmentMapper;
@Autowired
private DepartmentMapper departmentMapper;
@Autowired
private UserMapper userMapper;

//查询全部事件

public List<Appointment> getallapplist(){


for (Appointment ap : appointmentMapper.getlist()) {
ap.setDepa(departmentMapper.selectByPrimaryKey((Integer.valueOf(ap.getDepartment()))));
ap.setU(userMapper.selectByPrimaryKey((Integer.valueOf(ap.getUser()))));
}

return appointmentMapper.getlist();
}

 

连表查询的简单方法!!

标签:value   key   连表   ima   list   lis   sel   eof   source   

原文地址:http://www.cnblogs.com/motherfucker/p/7205099.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!