RequestScheduleDAO { @RequiresSession public List<RequestScheduleEntity> findByStatus(String status) { TypedQuery<RequestScheduleEntity> query = entityManagerProvider.get() .createNamedQuery("reqScheduleByStatus", RequestScheduleEntity.class); query.setParameter("status", status); try { return query.getResultList(); } catch (NoResultException ignored) { return null; } }  @RequiresSession RequestScheduleEntity findById(Long id); @RequiresSession List<RequestScheduleEntity> findByStatus(String status); @RequiresSession List<RequestScheduleEntity> findAll(); @Transactional void create(RequestScheduleEntity requestScheduleEntity); @Transactional RequestScheduleEntity merge(RequestScheduleEntity requestScheduleEntity); @Transactional void remove(RequestScheduleEntity requestScheduleEntity); @Transactional void removeByPK(Long id); @Transactional void refresh(RequestScheduleEntity requestScheduleEntity);  }
@Test public void testFindByStatus() throws Exception { RequestScheduleEntity scheduleEntity = createScheduleEntity(); List<RequestScheduleEntity> scheduleEntities = requestScheduleDAO .findByStatus("SCHEDULED"); Assert.assertNotNull(scheduleEntities); Assert.assertEquals(scheduleEntity, scheduleEntities.get(0)); }