@RequiresSession
  public List<HostRoleCommandEntity> findStatusRolesByPKs(Collection<Long> taskIds) {
    TypedQuery<Object[]> query = entityManagerProvider.get().createQuery(
      "SELECT task.taskId, task.status, task.role FROM HostRoleCommandEntity task WHERE task.taskId IN ?1 " +
        "ORDER BY task.taskId",
        Object[].class);

    List<HostRoleCommandEntity> result = new ArrayList<>();
    SQLOperations.batch(taskIds, SQLConstants.IN_ARGUMENT_MAX_SIZE, (chunk, currentBatch, totalBatches, totalSize) -> {
      List<Object[]> queryResult = daoUtils.selectList(query, chunk);
      result.addAll(queryResult.stream().map(
          o -> {
            HostRoleCommandEntity e = new HostRoleCommandEntity();
            e.setTaskId((Long) o[0]);
            e.setStatus(HostRoleStatus.valueOf(o[1].toString()));
            e.setRole(Role.valueOf(o[2].toString()));
            return e;
          }).collect(Collectors.toList()));

      return 0;
    });

    return Lists.newArrayList(result);
  }
Retrieves minimal host role command columns which are required to calculate stare state.
@param taskIds collection of host role commands to process.
@return minimized host role command entities.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/HostRoleCommandDAO.java