WidgetLayoutDAO { @RequiresSession public List<WidgetLayoutEntity> findByCluster(long clusterId) { TypedQuery<WidgetLayoutEntity> query = entityManagerProvider.get() .createNamedQuery("WidgetLayoutEntity.findByCluster", WidgetLayoutEntity.class); query.setParameter("clusterId", clusterId); return daoUtils.selectList(query); }  @RequiresSession WidgetLayoutEntity findById(Long id); @RequiresSession List<WidgetLayoutEntity> findByCluster(long clusterId); @RequiresSession List<WidgetLayoutEntity> findBySectionName(String sectionName); @RequiresSession List<WidgetLayoutEntity> findByName(Long clusterId, String layoutName, String userName); @RequiresSession List<WidgetLayoutEntity> findAll(); @Transactional void create(WidgetLayoutEntity widgetLayoutEntity); @Transactional void createWithFlush(WidgetLayoutEntity widgetLayoutEntity); @Transactional WidgetLayoutEntity merge(WidgetLayoutEntity widgetLayoutEntity); @Transactional WidgetLayoutEntity mergeWithFlush(WidgetLayoutEntity widgetLayoutEntity); @Transactional void remove(WidgetLayoutEntity widgetLayoutEntity); @Transactional void removeByPK(Long id); @Transactional void refresh(WidgetLayoutEntity widgetLayoutEntity);  }
@Test public void testFindByCluster() { createRecords(); Assert.assertEquals(0, widgetLayoutDAO.findByCluster(99999).size()); Assert.assertEquals(2, widgetLayoutDAO.findByCluster(clusterId).size()); }