コード例 #1
0
 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();
   }
 }
コード例 #2
0
 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();
   }
 }
コード例 #3
0
 public Company getCompany(String id) throws SQLException {
   Connection connection = oracleCM.getConnection();
   try {
     return companyDAO.find(id, connection);
   } finally {
     connection.close();
   }
 }
コード例 #4
0
 public Employee getEmployee(String id) throws SQLException {
   Connection connection = oracleCM.getConnection();
   try {
     return employeeDAO.find(id, connection);
   } finally {
     connection.close();
   }
 }