@RequiresSession
  public List<HostComponentDesiredStateEntity> findByHostsAndCluster(Collection<Long> hostIds, Long clusterId) {
    final EntityManager entityManager = entityManagerProvider.get();
    final TypedQuery<HostComponentDesiredStateEntity> query = entityManager.
        createNamedQuery("HostComponentDesiredStateEntity.findByHostsAndCluster", HostComponentDesiredStateEntity.class);

    final List<HostComponentDesiredStateEntity> result = new ArrayList<>();
    SQLOperations.batch(hostIds, SQLConstants.IN_ARGUMENT_MAX_SIZE, (chunk, currentBatch, totalBatches, totalSize) -> {
      query.setParameter("hostIds", chunk);
      query.setParameter("clusterId", clusterId);
      result.addAll(daoUtils.selectList(query));
      return 0;
    });
    return Lists.newArrayList(result);
  }
Retrieve the single Host Component Desired State for the given unique cluster, service, component, and host.

@param clusterId Cluster ID
@param serviceName Service Name
@param componentName Component Name
@return Return the Host Component Desired State entity that match the criteria.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostComponentDesiredStateDAO.java