@Test public void testFindById() { MonthlyReport report1 = MonthlyReport.from(3L, 2014, 3, new byte[SIZE_10MB], DateTime.now()); MonthlyReport report2 = MonthlyReport.from(4L, 2014, 4, new byte[SIZE_10MB], DateTime.now()); monthlyReportRepository.save(report1); monthlyReportRepository.save(report2); MonthlyReport searchedForReport = monthlyReportRepository.findById(report2.getId()); assertThat(searchedForReport.getId()).isEqualTo(report2.getId()); }
public MonthlyReport findById(Long id) { TypedQuery<MonthlyReport> typedQuery = entityManager.createNamedQuery(MonthlyReport.FIND_BY_ID, MonthlyReport.class); typedQuery.setParameter(MonthlyReport.ID, id); MonthlyReport monthlyReport; try { monthlyReport = typedQuery.getSingleResult(); } catch (NoResultException ex) { monthlyReport = null; } return monthlyReport; }
MonthlyReportRepository extends AbstractRepository<MonthlyReport> { public MonthlyReport findById(Long id) { TypedQuery<MonthlyReport> typedQuery = entityManager.createNamedQuery(MonthlyReport.FIND_BY_ID, MonthlyReport.class); typedQuery.setParameter(MonthlyReport.ID, id); MonthlyReport monthlyReport; try { monthlyReport = typedQuery.getSingleResult(); } catch (NoResultException ex) { monthlyReport = null; } return monthlyReport; } }
MonthlyReportRepository extends AbstractRepository<MonthlyReport> { public MonthlyReport findById(Long id) { TypedQuery<MonthlyReport> typedQuery = entityManager.createNamedQuery(MonthlyReport.FIND_BY_ID, MonthlyReport.class); typedQuery.setParameter(MonthlyReport.ID, id); MonthlyReport monthlyReport; try { monthlyReport = typedQuery.getSingleResult(); } catch (NoResultException ex) { monthlyReport = null; } return monthlyReport; }  }
MonthlyReportRepository extends AbstractRepository<MonthlyReport> { public MonthlyReport findById(Long id) { TypedQuery<MonthlyReport> typedQuery = entityManager.createNamedQuery(MonthlyReport.FIND_BY_ID, MonthlyReport.class); typedQuery.setParameter(MonthlyReport.ID, id); MonthlyReport monthlyReport; try { monthlyReport = typedQuery.getSingleResult(); } catch (NoResultException ex) { monthlyReport = null; } return monthlyReport; }  MonthlyReport findByYearAndMonth(int year, int month); MonthlyReport findById(Long id); }
MonthlyReportRepository extends AbstractRepository<MonthlyReport> { public MonthlyReport findById(Long id) { TypedQuery<MonthlyReport> typedQuery = entityManager.createNamedQuery(MonthlyReport.FIND_BY_ID, MonthlyReport.class); typedQuery.setParameter(MonthlyReport.ID, id); MonthlyReport monthlyReport; try { monthlyReport = typedQuery.getSingleResult(); } catch (NoResultException ex) { monthlyReport = null; } return monthlyReport; }  MonthlyReport findByYearAndMonth(int year, int month); MonthlyReport findById(Long id);  }