code: public static NamedQuery findNamedQuery(Class<?> type, String name)
      {
          NamedQuery annotatedNamedQuery = (NamedQuery) type.getAnnotation(NamedQuery.class);
          if (annotatedNamedQuery != null) {
              return annotatedNamedQuery;
          }
  
          NamedQueries annotatedNamedQueries = (NamedQueries) type.getAnnotation(NamedQueries.class);
          if (annotatedNamedQueries != null) {
              NamedQuery[] namedQueries = annotatedNamedQueries.value();
              if (namedQueries != null) {
                  for (NamedQuery namedQuery : namedQueries) {
                      if (namedQuery.name().equalsIgnoreCase(name)) {
                          return namedQuery;
                      }
                  }
              }
          }
          // no named query with that name
          log.debug("No NamedQuery with name '{}' exists for type '{}'", name, type);
          return null;
      }
docs: get a named query from an entity
  
  @param type
  @param name
  @return