@Test public void testFind() { setupSomeEmployeesAndMonthlyTaxes(); MonthlyTaxForEmployee monthlyTaxForEmployee = monthlyTaxForEmployeeRepository.find(ionel, 2014, 1); assertThat(monthlyTaxForEmployee).isEqualsToByComparingFields(ionelJanuary); }
public MonthlyTaxForEmployee find(Employee employee, int year, int month) { TypedQuery<MonthlyTaxForEmployee> typedQuery = entityManager.createNamedQuery(MonthlyTaxForEmployee.FIND_BY_EMPLOYEE_YEAR_AND_MONTH, MonthlyTaxForEmployee.class); typedQuery.setParameter("employeeId", employee.getId()); typedQuery.setParameter("year", year); typedQuery.setParameter("month", month); return typedQuery.getResultList() .stream() .findAny() .orElse(null); }
MonthlyTaxForEmployeeRepository extends AbstractRepository<MonthlyTaxForEmployee> { public MonthlyTaxForEmployee find(Employee employee, int year, int month) { TypedQuery<MonthlyTaxForEmployee> typedQuery = entityManager.createNamedQuery(MonthlyTaxForEmployee.FIND_BY_EMPLOYEE_YEAR_AND_MONTH, MonthlyTaxForEmployee.class); typedQuery.setParameter("employeeId", employee.getId()); typedQuery.setParameter("year", year); typedQuery.setParameter("month", month); return typedQuery.getResultList() .stream() .findAny() .orElse(null); } }
MonthlyTaxForEmployeeRepository extends AbstractRepository<MonthlyTaxForEmployee> { public MonthlyTaxForEmployee find(Employee employee, int year, int month) { TypedQuery<MonthlyTaxForEmployee> typedQuery = entityManager.createNamedQuery(MonthlyTaxForEmployee.FIND_BY_EMPLOYEE_YEAR_AND_MONTH, MonthlyTaxForEmployee.class); typedQuery.setParameter("employeeId", employee.getId()); typedQuery.setParameter("year", year); typedQuery.setParameter("month", month); return typedQuery.getResultList() .stream() .findAny() .orElse(null); }  }
MonthlyTaxForEmployeeRepository extends AbstractRepository<MonthlyTaxForEmployee> { public MonthlyTaxForEmployee find(Employee employee, int year, int month) { TypedQuery<MonthlyTaxForEmployee> typedQuery = entityManager.createNamedQuery(MonthlyTaxForEmployee.FIND_BY_EMPLOYEE_YEAR_AND_MONTH, MonthlyTaxForEmployee.class); typedQuery.setParameter("employeeId", employee.getId()); typedQuery.setParameter("year", year); typedQuery.setParameter("month", month); return typedQuery.getResultList() .stream() .findAny() .orElse(null); }  @Override @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT) MonthlyTaxForEmployee save(MonthlyTaxForEmployee entity); List<MonthlyTaxForEmployee> findByEmployee(Employee employee); MonthlyTaxForEmployee find(Employee employee, int year, int month); }
MonthlyTaxForEmployeeRepository extends AbstractRepository<MonthlyTaxForEmployee> { public MonthlyTaxForEmployee find(Employee employee, int year, int month) { TypedQuery<MonthlyTaxForEmployee> typedQuery = entityManager.createNamedQuery(MonthlyTaxForEmployee.FIND_BY_EMPLOYEE_YEAR_AND_MONTH, MonthlyTaxForEmployee.class); typedQuery.setParameter("employeeId", employee.getId()); typedQuery.setParameter("year", year); typedQuery.setParameter("month", month); return typedQuery.getResultList() .stream() .findAny() .orElse(null); }  @Override @Transactional(propagation = Propagation.REQUIRES_NEW, isolation = Isolation.DEFAULT) MonthlyTaxForEmployee save(MonthlyTaxForEmployee entity); List<MonthlyTaxForEmployee> findByEmployee(Employee employee); MonthlyTaxForEmployee find(Employee employee, int year, int month);  }