The project is Hibernate+jquery-easyui, the introduction of the multi-table associated with the deletion and modification operations.
It's simple: you just need to insert data in a table that is associated with a multi-table, such as a departmental table that is associated with an employee table, and you cannot insert the associated department directly through a Web page submission form, but you want to add data through the object in the new object at the controller.
Increase
The code under the servlet is dept dept = Deptservice.findbyidifo (Integer.parseint (Req.getparameter ("DeptID")); Employee.setdept ( dept);//finally add the employee Saveempinfo corresponding method written in the service layer and DAO layer in this ignore empservice.saveempinfo (employee);
Delete
Deleting the row data directly, such as Empid (f_id back to the backend via the foreground), does not need to be processed
Modify
Department Dept Dept = New Dept (); Boolean Flag1 = true;//Find All department information Loop comparison (need to use reserved columns) 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);
This article is from "Lovely Xiaopp" blog, reprint please contact the author!
The operation of adding and deleting multiple table associations under Jquery-easyui