congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
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

  • Making http post requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getApplicationContext (Context)
  • getExternalFilesDir (Context)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • PhpStorm for WordPress
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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