您好,登錄后才能下訂單哦!
項(xiàng)目用的是Hibernate+Jquery-easyui,介紹的是多表關(guān)聯(lián)的增刪改操作。
很簡(jiǎn)單:只需要在多表關(guān)聯(lián)的表,如員工表中關(guān)聯(lián)了部門表插入數(shù)據(jù)時(shí)不能直接通過網(wǎng)頁(yè)提交表單插入關(guān)聯(lián)的部門,需要在Controller處的new一個(gè)對(duì)象,通過對(duì)象添加數(shù)據(jù)。
增加
//Servlet下的代碼 Dept dept = deptService.findByIdIfo(Integer.parseInt(req.getParameter("deptId"))); employee.setDept(dept); //最后把employee添加 saveEmpInfo相應(yīng)方法寫在service層和dao層在此忽略 empService.saveEmpInfo(employee);
刪除
直接刪除該行數(shù)據(jù)如empId(通過前臺(tái)傳回后臺(tái)的f_id),不需要做處理
修改
// 部門 Dept dept = new Dept(); boolean flag1 = true; //查找全部部門信息循環(huán)比較(需要用到預(yù)留列) 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);
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。