@RequiresSession
  public ResourceEntity findResourceForViewInstance(String viewName,
      String instanceName) {
    TypedQuery<ResourceEntity> query = entityManagerProvider.get().createNamedQuery(
        "getResourceIdByViewInstance", ResourceEntity.class);

    query.setParameter("viewName", viewName);
    query.setParameter("instanceName", instanceName);

    return daoUtils.selectOne(query);
  }
Gets the associated {@link ResourceEntity} for a given instance.

@param viewName
         the name of the view
@param instanceName
         the name of the view instance

@return the associated resource entity or {@code null}.
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ViewInstanceDAO.java