@RequiresSession
  public List<PermissionEntity> findPermissionsByPrincipal(List<PrincipalEntity> principalList) {
    TypedQuery<PermissionEntity> query = entityManagerProvider.get().createNamedQuery("PermissionEntity.findByPrincipals", PermissionEntity.class);

    List<PermissionEntity> result = new ArrayList<>();
    SQLOperations.batch(principalList, SQLConstants.IN_ARGUMENT_MAX_SIZE, (chunk, currentBatch, totalBatches, totalSize) -> {
      query.setParameter("principalList", chunk);
      result.addAll(daoUtils.selectList(query));
      return 0;
    });
    return Lists.newArrayList(result);
  }
Find the permission entities for the given list of principals

@param principalList  the list of principal entities

@return the list of permissions (or roles) matching the query
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PermissionDAO.java