@RequiresSession
  public HostComponentDesiredStateEntity findByIndex(Long clusterId, String serviceName,
                                                     String componentName, Long hostId) {
    final TypedQuery<HostComponentDesiredStateEntity> query = entityManagerProvider.get()
      .createNamedQuery("HostComponentDesiredStateEntity.findByIndexAndHost", HostComponentDesiredStateEntity.class);

    query.setParameter("clusterId", clusterId);
    query.setParameter("serviceName", serviceName);
    query.setParameter("componentName", componentName);
    query.setParameter("hostId", hostId);

    return daoUtils.selectSingle(query);
  }
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
@param hostId Host ID
@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