EmployeeDAO { @Transactional(propagation = Propagation.SUPPORTS) public Employee getById(String employeeId) { Employee employee = findById(employeeId); if (employee == null) { throw new RuntimeException("Employee not found for id " + employeeId); } return employee; } @Autowired  EmployeeDAO(DataSource dataSource); void persist(Employee employee); void removeById(String employeeId); void update(Employee employee); @Transactional(propagation = Propagation.SUPPORTS) // ! Needed for SPring to Proxy this method. The proxy will kill the Tx when you exit on Exception Employee getById(String employeeId); Employee findById(String employeeId); int countByPhone(String newPhone);  }
@Test public void afterPersist_getReturnsTheSameEmployee() { Employee fromDB = dao.getById(employeeInDatabase.getId()); assertEquals(employeeInDatabase.getName(), fromDB.getName()); assertEquals(employeeInDatabase.getPhone(), fromDB.getPhone()); }