List of usage examples for com.amazonaws.services.dynamodbv2.model QueryRequest setAttributesToGet
public void setAttributesToGet(java.util.Collection<String> attributesToGet)
This is a legacy parameter.
From source file:com.vivastream.dynamodb.core.DynamoDBTemplate.java
License:Apache License
public <T> List<T> query(String tableName, String indexName, Map<String, Condition> keyConditions, final ObjectExtractor<T> extractor, String... columnsToInclude) throws EmptyResultDataAccessException { Assert.notNull(tableName, "Table must not be null"); Assert.notNull(extractor, "ObjectExtractor must not be null"); if (logger.isDebugEnabled()) { logger.debug("Executing query on " + tableName + " for " + renderKey(keyConditions)); }/* w w w . j a v a 2 s.c o m*/ QueryRequest request = new QueryRequest(tableName) // .withConsistentRead(false) // because query is used on GSIs [where consistent reads are not supported] - if we needed to query on the primary index could make this a parameter .withKeyConditions(keyConditions); if (columnsToInclude != null && columnsToInclude.length > 0) { request.setAttributesToGet(Arrays.asList(columnsToInclude)); } if (indexName != null) { request.setIndexName(indexName); } QueryResult result = client.query(request); List<Map<String, AttributeValue>> items = result.getItems(); List<T> convertedItems = new ArrayList<T>(items.size()); for (Map<String, AttributeValue> item : items) { convertedItems.add(extractor.extract(item)); } return convertedItems; }