码迷,mamicode.com
首页 > Web开发 > 详细

jQuery-easyui下的多表关联的增删改操作

时间:2014-09-18 09:56:34      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:多表关联   easyui   增删改   

项目用的是Hibernate+Jquery-easyui,介绍的是多表关联的增删改操作。

很简单:只需要在多表关联的表,如员工表中关联了部门表插入数据时不能直接通过网页提交表单插入关联的部门,需要在Controller处的new一个对象,通过对象添加数据。

增加

//Servlet下的代码
Dept dept = deptService.findByIdIfo(Integer.parseInt(req.getParameter("deptId")));
employee.setDept(dept);
//最后把employee添加  saveEmpInfo相应方法写在service层和dao层在此忽略
empService.saveEmpInfo(employee);


删除

直接删除该行数据如empId(通过前台传回后台的f_id),不需要做处理


修改

// 部门
Dept dept = new Dept();
boolean flag1 = true;
//查找全部部门信息循环比较(需要用到预留列)
			List<Dept> list1 = deptService.findAllInfo();
			for (Dept d : list1) {
				if (d.getDeptName().equals(req.getParameter("deptId"))) {
					flag1 = false;
				}
			}
			if (!flag1) {
				employee.setDeptTemp(req.getParameter("deptId"));
			} else {
				dept = deptService.findByIdIfo(Integer.parseInt(req
						.getParameter("deptId")));
				employee.setDept(dept);
			}
			empService.updateEmpInfo(employee);


本文出自 “可爱的xiaopp” 博客,转载请与作者联系!

jQuery-easyui下的多表关联的增删改操作

标签:多表关联   easyui   增删改   

原文地址:http://smartxiaopp.blog.51cto.com/9349053/1554555

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