@RequiresSession
  public List<PrivilegeEntity> findByResourceId(Long id) {
    TypedQuery<PrivilegeEntity> query = entityManagerProvider.get().createQuery("SELECT privilege FROM PrivilegeEntity privilege WHERE privilege.resource.id = :resource_id", PrivilegeEntity.class);
    query.setParameter("resource_id", id);
    return daoUtils.selectList(query);
  }
Find all privileges for given resource.

@param id ID of the resource
@return all resource privileges or an empty list
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/PrivilegeDAO.java