Tabnine Logo
KeyValueOperations.find
Code IndexAdd Tabnine to your IDE (free)

How to use
find
method
in
org.springframework.data.keyvalue.core.KeyValueOperations

Best Java code snippets using org.springframework.data.keyvalue.core.KeyValueOperations.find (Showing top 6 results out of 315)

origin: com.hazelcast/spring-data-hazelcast

/**
 * Execute a "delete" query, not really a query more of an operation.
 * <p>
 *
 * @param query       The query to run
 * @param queryMethod Used here to find the type of object to match the query
 * @return Collection of deleted objects or the number of deleted objects
 */
private Object executeDeleteQuery(final KeyValueQuery<?> query, final QueryMethod queryMethod) {
  Iterable<?> resultSet = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
  Iterator<?> iterator = resultSet.iterator();
  List<Object> result = new ArrayList<>();
  while (iterator.hasNext()) {
    result.add(this.keyValueOperations.delete(iterator.next()));
  }
  if (queryMethod.isCollectionQuery()) {
    return result;
  } else if (long.class.equals(queryMethod.getReturnedObjectType()) || Long.class
      .equals(queryMethod.getReturnedObjectType())) {
    return result.size();
  } else {
    throw new UnsupportedOperationException(String.format(
        "Illegal returned type: %s. The operation 'deleteBy' accepts only 'long' and 'Collection' as the returned "
            + "object type", queryMethod.getReturnedObjectType()));
  }
}
origin: com.hazelcast/spring-data-hazelcast

/**
 * <p>
 * Execute a retrieval query. The query engine will return this in an iterator, which may need conversion to a single
 * domain entity or a stream.
 * </P>
 *
 * @param query       The query to run
 * @param queryMethod Holds metadata about the query, is paging etc
 * @return Query result
 */
private Object executeFindQuery(final KeyValueQuery<?> query, final QueryMethod queryMethod) {
  Iterable<?> resultSet = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
  if (!queryMethod.isCollectionQuery() && !queryMethod.isPageQuery() && !queryMethod.isSliceQuery() && !queryMethod
      .isStreamQuery()) {
    // Singleton result
    return resultSet.iterator().hasNext() ? resultSet.iterator().next() : null;
  }
  if (queryMethod.isStreamQuery()) {
    return StreamUtils.createStreamFromIterator(resultSet.iterator());
  }
  return resultSet;
}
origin: apache/servicemix-bundles

/**
 * @param parameters
 * @param query
 */
@Nullable
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object doExecute(Object[] parameters, KeyValueQuery<?> query) {
  if (queryMethod.isPageQuery() || queryMethod.isSliceQuery()) {
    Pageable page = (Pageable) parameters[queryMethod.getParameters().getPageableIndex()];
    query.setOffset(page.getOffset());
    query.setRows(page.getPageSize());
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    long count = queryMethod.isSliceQuery() ? 0
        : keyValueOperations.count(query, queryMethod.getEntityInformation().getJavaType());
    return new PageImpl(IterableConverter.toList(result), page, count);
  } else if (queryMethod.isCollectionQuery()) {
    return this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
  } else if (queryMethod.isQueryForEntity()) {
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    return result.iterator().hasNext() ? result.iterator().next() : null;
  }
  throw new UnsupportedOperationException("Query method not supported.");
}
origin: spring-projects/spring-data-keyvalue

/**
 * @param parameters
 * @param query
 */
@Nullable
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object doExecute(Object[] parameters, KeyValueQuery<?> query) {
  if (queryMethod.isPageQuery() || queryMethod.isSliceQuery()) {
    Pageable page = (Pageable) parameters[queryMethod.getParameters().getPageableIndex()];
    query.setOffset(page.getOffset());
    query.setRows(page.getPageSize());
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    long count = queryMethod.isSliceQuery() ? 0
        : keyValueOperations.count(query, queryMethod.getEntityInformation().getJavaType());
    return new PageImpl(IterableConverter.toList(result), page, count);
  } else if (queryMethod.isCollectionQuery()) {
    return this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
  } else if (queryMethod.isQueryForEntity()) {
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    return result.iterator().hasNext() ? result.iterator().next() : null;
  }
  throw new UnsupportedOperationException("Query method not supported.");
}
origin: org.springframework.data/spring-data-keyvalue

/**
 * @param parameters
 * @param query
 */
@Nullable
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object doExecute(Object[] parameters, KeyValueQuery<?> query) {
  if (queryMethod.isPageQuery() || queryMethod.isSliceQuery()) {
    Pageable page = (Pageable) parameters[queryMethod.getParameters().getPageableIndex()];
    query.setOffset(page.getOffset());
    query.setRows(page.getPageSize());
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    long count = queryMethod.isSliceQuery() ? 0
        : keyValueOperations.count(query, queryMethod.getEntityInformation().getJavaType());
    return new PageImpl(IterableConverter.toList(result), page, count);
  } else if (queryMethod.isCollectionQuery()) {
    return this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
  } else if (queryMethod.isQueryForEntity()) {
    Iterable<?> result = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
    return result.iterator().hasNext() ? result.iterator().next() : null;
  }
  throw new UnsupportedOperationException("Query method not supported.");
}
origin: com.hazelcast/spring-data-hazelcast

query.setRows(pageRequest.getPageSize());
Iterable<?> resultSet = this.keyValueOperations.find(query, queryMethod.getEntityInformation().getJavaType());
List<?> content = IterableConverter.toList(resultSet);
org.springframework.data.keyvalue.coreKeyValueOperationsfind

Javadoc

Get all elements matching the given query.
Respects KeySpace if present and therefore returns all elements that can be assigned to requested type..

Popular methods of KeyValueOperations

  • getMappingContext
  • count
    Total number of elements matching given query. Respects KeySpace if present and therefore counts all
  • delete
    Delete item of type with given id.
  • destroy
  • findAll
    Get all elements ordered by sort. Respects KeySpace if present and therefore returns all elements th
  • findById
    Get element of given type with given id. Respects KeySpace if present and therefore returns all elem
  • findInRange
    Get all elements in given range ordered by sort. Respects KeySpace if present and therefore returns
  • insert
    Add object with given id.
  • update

Popular in Java

  • Start an intent from android
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getSupportFragmentManager (FragmentActivity)
  • getResourceAsStream (ClassLoader)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • JList (javax.swing)
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now