ClusterVersionDAO extends CrudDAO<ClusterVersionEntity, Long> { @RequiresSession public List<ClusterVersionEntity> findByStackAndVersion(String stackName, String stackVersion, String version) { final TypedQuery<ClusterVersionEntity> query = entityManagerProvider.get().createNamedQuery("clusterVersionByStackVersion", ClusterVersionEntity.class); query.setParameter("stackName", stackName); query.setParameter("stackVersion", stackVersion); query.setParameter("version", version); return daoUtils.selectList(query); } ClusterVersionDAO(); @RequiresSession List<ClusterVersionEntity> findByStackAndVersion(String stackName,
      String stackVersion, String version); @RequiresSession ClusterVersionEntity findByClusterAndStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<ClusterVersionEntity> findByCluster(String clusterName); @RequiresSession ClusterVersionEntity findByClusterAndStateCurrent(String clusterName); @RequiresSession List<ClusterVersionEntity> findByClusterAndState(String clusterName, RepositoryVersionState state); @Override @Transactional void create(ClusterVersionEntity entity); @Transactional ClusterVersionEntity create(ClusterEntity cluster, RepositoryVersionEntity repositoryVersion,
                                     RepositoryVersionState state, long startTime, long endTime, String userName); @Transactional void updateVersions(Long clusterId, RepositoryVersionEntity target, RepositoryVersionEntity current);  }
@Test public void testFindByStackAndVersion() throws Exception { createRecordsUntilStep(1); Assert.assertEquals( 0, clusterVersionDAO.findByStackAndVersion("non existing", "non existing", "non existing").size()); Assert.assertEquals( 1, clusterVersionDAO.findByStackAndVersion(HDP_22_STACK.getStackName(), HDP_22_STACK.getStackVersion(), "2.2.0.0-995").size()); }