@Test public void testDuplicates() throws Exception { HostEntity host1 = hostDAO.findByName("test_host1"); RepositoryVersionEntity repoVersion = helper.getOrCreateRepositoryVersion(HDP_22_STACK, repoVersion_2200); HostVersionEntity hostVersionEntity1 = new HostVersionEntity(host1, repoVersion, RepositoryVersionState.CURRENT); try { hostVersionDAO.create(hostVersionEntity1); Assert.fail("Each host can have a relationship to a repo version, but cannot have more than one for the same repo"); } catch (Exception e) { } }
@Override @Transactional public void create(HostVersionEntity entity) throws IllegalArgumentException{ if (entity.getRepositoryVersion() == null) { throw new IllegalArgumentException("RepositoryVersion argument is not set for the entity"); } super.create(entity); entity.getRepositoryVersion().updateHostVersionEntityRelation(entity); }
HostVersionDAO extends CrudDAO<HostVersionEntity, Long> { @Override @Transactional public void create(HostVersionEntity entity) throws IllegalArgumentException{ if (entity.getRepositoryVersion() == null) { throw new IllegalArgumentException("RepositoryVersion argument is not set for the entity"); } super.create(entity); entity.getRepositoryVersion().updateHostVersionEntityRelation(entity); } }
HostVersionDAO extends CrudDAO<HostVersionEntity, Long> { @Override @Transactional public void create(HostVersionEntity entity) throws IllegalArgumentException{ if (entity.getRepositoryVersion() == null) { throw new IllegalArgumentException("RepositoryVersion argument is not set for the entity"); } super.create(entity); entity.getRepositoryVersion().updateHostVersionEntityRelation(entity); } HostVersionDAO(); }
HostVersionDAO extends CrudDAO<HostVersionEntity, Long> { @Override @Transactional public void create(HostVersionEntity entity) throws IllegalArgumentException{ if (entity.getRepositoryVersion() == null) { throw new IllegalArgumentException("RepositoryVersion argument is not set for the entity"); } super.create(entity); entity.getRepositoryVersion().updateHostVersionEntityRelation(entity); } HostVersionDAO(); @Override @Transactional void create(HostVersionEntity entity); @RequiresSession List<HostVersionEntity> findByClusterStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<HostVersionEntity> findByHost(String hostName); @RequiresSession List<HostVersionEntity> findByClusterAndHost(String  clusterName, String hostName); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(String  clusterName, String hostName, RepositoryVersionState state); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(long clusterId, long hostId, RepositoryVersionState state); @RequiresSession HostVersionEntity findByHostAndStateCurrent(String clusterName, String hostName); @RequiresSession HostVersionEntity findByHostAndStateCurrent(long clusterId, long hostId); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(String clusterName,
      StackId stackId, String version, String hostName); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(long clusterId, StackId stackId, String version,
                                                            long hostId); @Transactional void removeByHostName(String hostName); @Transactional void updateVersions(RepositoryVersionEntity target, RepositoryVersionEntity current); }
HostVersionDAO extends CrudDAO<HostVersionEntity, Long> { @Override @Transactional public void create(HostVersionEntity entity) throws IllegalArgumentException{ if (entity.getRepositoryVersion() == null) { throw new IllegalArgumentException("RepositoryVersion argument is not set for the entity"); } super.create(entity); entity.getRepositoryVersion().updateHostVersionEntityRelation(entity); } HostVersionDAO(); @Override @Transactional void create(HostVersionEntity entity); @RequiresSession List<HostVersionEntity> findByClusterStackAndVersion(
      String clusterName, StackId stackId, String version); @RequiresSession List<HostVersionEntity> findByHost(String hostName); @RequiresSession List<HostVersionEntity> findByClusterAndHost(String  clusterName, String hostName); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(String  clusterName, String hostName, RepositoryVersionState state); @RequiresSession List<HostVersionEntity> findByClusterHostAndState(long clusterId, long hostId, RepositoryVersionState state); @RequiresSession HostVersionEntity findByHostAndStateCurrent(String clusterName, String hostName); @RequiresSession HostVersionEntity findByHostAndStateCurrent(long clusterId, long hostId); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(String clusterName,
      StackId stackId, String version, String hostName); @RequiresSession HostVersionEntity findByClusterStackVersionAndHost(long clusterId, StackId stackId, String version,
                                                            long hostId); @Transactional void removeByHostName(String hostName); @Transactional void updateVersions(RepositoryVersionEntity target, RepositoryVersionEntity current);  }