public void hireEmployee(Employee hiredEmployee, Company toCompany) throws SQLException { Connection connection = oracleCM.getConnection(); try { connection.setAutoCommit(false); employeeDAO.save(hiredEmployee, connection); Company company = companyDAO.find(toCompany.getId(), connection); company.getEmployees().add(hiredEmployee); companyDAO.update(company, connection); connection.commit(); } finally { connection.setAutoCommit(true); connection.close(); } }
public void fireEmployee(Employee firedEmployee, Company fromCompany) throws SQLException { Connection connection = oracleCM.getConnection(); try { connection.setAutoCommit(false); Company company = companyDAO.find(fromCompany.getId(), connection); company.getEmployees().remove(firedEmployee); companyDAO.update(company, connection); employeeDAO.delete(firedEmployee, connection); connection.commit(); } finally { connection.setAutoCommit(true); connection.close(); } }
public Company getCompany(String id) throws SQLException { Connection connection = oracleCM.getConnection(); try { return companyDAO.find(id, connection); } finally { connection.close(); } }
public Employee getEmployee(String id) throws SQLException { Connection connection = oracleCM.getConnection(); try { return employeeDAO.find(id, connection); } finally { connection.close(); } }