BAEL-3961 Make the program more robust by only create the table when necessary and clean all data in the temp table.
This commit is contained in:
parent
63027fd269
commit
78e180f35d
@ -45,7 +45,8 @@ public class EmployeeDAO {
|
||||
}
|
||||
|
||||
public List<Employee> getEmployeesFromLargeIdList(List<Integer> ids) {
|
||||
jdbcTemplate.execute("CREATE TEMPORARY TABLE employee_tmp (id INT NOT NULL)");
|
||||
jdbcTemplate.execute("CREATE TEMPORARY TABLE IF NOT EXISTS employee_tmp (id INT NOT NULL)");
|
||||
jdbcTemplate.update("DELETE FROM employee_tmp");
|
||||
|
||||
List<Object[]> employeeIds = new ArrayList<>();
|
||||
for (Integer id : ids) {
|
||||
|
@ -98,5 +98,10 @@ public class EmployeeDAOUnitTest {
|
||||
assertEquals(1, employees.get(0).getId());
|
||||
assertEquals(3, employees.get(1).getId());
|
||||
assertEquals(4, employees.get(2).getId());
|
||||
|
||||
ids.clear();
|
||||
ids.add(2);
|
||||
employees = employeeDAO.getEmployeesFromLargeIdList(ids);
|
||||
assertEquals(1, employees.size());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user