WidgetDAO { @RequiresSession public List<WidgetEntity> findByCluster(long clusterId) { TypedQuery<WidgetEntity> query = entityManagerProvider.get() .createNamedQuery("WidgetEntity.findByCluster", WidgetEntity.class); query.setParameter("clusterId", clusterId); return daoUtils.selectList(query); }  @RequiresSession WidgetEntity findById(Long id); @RequiresSession List<WidgetEntity> findByCluster(long clusterId); @RequiresSession List<WidgetEntity> findBySectionName(String sectionName); @RequiresSession List<WidgetEntity> findByName(Long clusterId, String widgetName, String author, String defaultSectionName); @RequiresSession List<WidgetEntity> findByScopeOrAuthor(String author, String scope); @RequiresSession List<WidgetEntity> findAll(); @Transactional void create(WidgetEntity widgetEntity); @Transactional WidgetEntity merge(WidgetEntity widgetEntity); @Transactional void remove(WidgetEntity widgetEntity); @Transactional void removeByPK(Long id); @Transactional void refresh(WidgetEntity widgetEntity);  }
@Test public void testFindByCluster() { createRecords(); Assert.assertEquals(0, widgetDAO.findByCluster(99999).size()); Assert.assertEquals(3, widgetDAO.findByCluster(clusterId).size()); }