@RequiresSession
  public List<PrincipalEntity> findByPermissionId(Integer id) {
    TypedQuery<PrincipalEntity> query = entityManagerProvider.get().createNamedQuery("principalByPrivilegeId", PrincipalEntity.class);
    query.setParameter("permission_id", id);
    return daoUtils.selectList(query);
  }
Find principals having specified permission.

@param id permission id
@return all principals having specified permission
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PrincipalDAO.java