@RequiresSession
  public ResourceEntity findByResourceTypeId(Integer id) {
    TypedQuery<ResourceEntity> query = entityManagerProvider.get().createQuery(
        "SELECT resource FROM ResourceEntity resource WHERE resource.resourceType.id =:resourceTypeId",
        ResourceEntity.class);
    query.setParameter("resourceTypeId", id);
    try {
      return query.getSingleResult();
    } catch (NoResultException e) {
      return null;
    }
  }
Find a resource with the given resource type id.

@param id  type id

@return  a matching resource or null
ambari-server/src/main/java/org/apache/ambari/server/orm/dao/ResourceDAO.java