@RequiresSession
  public ViewInstanceEntity findByResourceId(long resourceId) {
    TypedQuery<ViewInstanceEntity> query = entityManagerProvider.get().createNamedQuery("viewInstanceByResourceId", ViewInstanceEntity.class);
    query.setParameter("resourceId", resourceId);
    try {
      return query.getSingleResult();
    } catch (NoResultException ignored) {
      return null;
    }
  }
Find a view instance by given resource id.

@param resourceId resource id
@return a matching view instance or null
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ViewInstanceDAO.java