@Test public void testFindMaxVersions() throws Exception { createServiceConfig("HDFS", "admin", 1L, 1L, 1111L, null); createServiceConfig("HDFS", "admin", 2L, 2L, 2222L, null); createServiceConfig("YARN", "admin", 1L, 3L, 3333L, null); long hdfsVersion = serviceConfigDAO.findNextServiceConfigVersion( clusterDAO.findByName("c1").getClusterId(), "HDFS"); long yarnVersion = serviceConfigDAO.findNextServiceConfigVersion( clusterDAO.findByName("c1").getClusterId(), "YARN"); Assert.assertEquals(3, hdfsVersion); Assert.assertEquals(2, yarnVersion); }
@RequiresSession public Long findNextServiceConfigVersion(long clusterId, String serviceName) { TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findNextServiceConfigVersion", Number.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); return daoUtils.selectSingle(query).longValue(); }
ServiceConfigDAO { @RequiresSession public Long findNextServiceConfigVersion(long clusterId, String serviceName) { TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findNextServiceConfigVersion", Number.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); return daoUtils.selectSingle(query).longValue(); } }
ServiceConfigDAO { @RequiresSession public Long findNextServiceConfigVersion(long clusterId, String serviceName) { TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findNextServiceConfigVersion", Number.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); return daoUtils.selectSingle(query).longValue(); }  }
ServiceConfigDAO { @RequiresSession public Long findNextServiceConfigVersion(long clusterId, String serviceName) { TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findNextServiceConfigVersion", Number.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); return daoUtils.selectSingle(query).longValue(); }  @RequiresSession ServiceConfigEntity find(Long serviceConfigId); @RequiresSession ServiceConfigEntity findByServiceAndVersion(String serviceName, Long version); @RequiresSession List<ServiceConfigEntity> findByService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigVersionsForGroups(Collection<Long> configGroupIds); @RequiresSession List<Long> getServiceConfigVersionsByConfig(Long clusterId, String configType, Long configVersion); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId,
      StackId stackId); @RequiresSession List<ServiceConfigEntity> getLatestServiceConfigs(Long clusterId,
      StackId stackId); @RequiresSession ServiceConfigEntity getLastServiceConfig(Long clusterId, String serviceName); @RequiresSession ServiceConfigEntity findMaxVersion(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> findAll(); @RequiresSession Long findNextServiceConfigVersion(long clusterId, String serviceName); @Transactional void removeHostFromServiceConfigs(final Long hostId); @Transactional void create(ServiceConfigEntity serviceConfigEntity); @Transactional ServiceConfigEntity merge(ServiceConfigEntity serviceConfigEntity); @Transactional void remove(ServiceConfigEntity serviceConfigEntity); }
ServiceConfigDAO { @RequiresSession public Long findNextServiceConfigVersion(long clusterId, String serviceName) { TypedQuery<Number> query = entityManagerProvider.get().createNamedQuery( "ServiceConfigEntity.findNextServiceConfigVersion", Number.class); query.setParameter("clusterId", clusterId); query.setParameter("serviceName", serviceName); return daoUtils.selectSingle(query).longValue(); }  @RequiresSession ServiceConfigEntity find(Long serviceConfigId); @RequiresSession ServiceConfigEntity findByServiceAndVersion(String serviceName, Long version); @RequiresSession List<ServiceConfigEntity> findByService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigVersionsForGroups(Collection<Long> configGroupIds); @RequiresSession List<Long> getServiceConfigVersionsByConfig(Long clusterId, String configType, Long configVersion); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> getLastServiceConfigsForService(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getAllServiceConfigsForClusterAndStack(Long clusterId,
      StackId stackId); @RequiresSession List<ServiceConfigEntity> getLatestServiceConfigs(Long clusterId,
      StackId stackId); @RequiresSession ServiceConfigEntity getLastServiceConfig(Long clusterId, String serviceName); @RequiresSession ServiceConfigEntity findMaxVersion(Long clusterId, String serviceName); @RequiresSession List<ServiceConfigEntity> getServiceConfigs(Long clusterId); @RequiresSession List<ServiceConfigEntity> findAll(); @RequiresSession Long findNextServiceConfigVersion(long clusterId, String serviceName); @Transactional void removeHostFromServiceConfigs(final Long hostId); @Transactional void create(ServiceConfigEntity serviceConfigEntity); @Transactional ServiceConfigEntity merge(ServiceConfigEntity serviceConfigEntity); @Transactional void remove(ServiceConfigEntity serviceConfigEntity);  }