Skip to content

Instantly share code, notes, and snippets.

@adit2787
Created February 16, 2015 13:13
Show Gist options
  • Save adit2787/7fc4c7afa3aa41c69c41 to your computer and use it in GitHub Desktop.
Save adit2787/7fc4c7afa3aa41c69c41 to your computer and use it in GitHub Desktop.
Many To Many doView()
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
try {
Employee employee;
employee = EmployeeLocalServiceUtil.createEmployee(CounterLocalServiceUtil.increment());
employee.setAddress("Delhi");
employee.setName("Ramesh");
employee = EmployeeLocalServiceUtil.addEmployee(employee);
Department department1,department2;
department1 = DepartmentLocalServiceUtil.createDepartment(CounterLocalServiceUtil.increment());
department1.setDepartment("IT");
department1 =DepartmentLocalServiceUtil.addDepartment(department1);
department2 = DepartmentLocalServiceUtil.createDepartment(CounterLocalServiceUtil.increment());
department2.setDepartment("Research");
department2 =DepartmentLocalServiceUtil.addDepartment(department2);
DepartmentLocalServiceUtil.addEmployeeDepartments(employee.getEid(), new long[]{department1.getDeptid(),department2.getDeptid()});
}
catch (SystemException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment