Example usage for com.amazonaws.services.dynamodbv2.model KeysAndAttributes setProjectionExpression

List of usage examples for com.amazonaws.services.dynamodbv2.model KeysAndAttributes setProjectionExpression

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model KeysAndAttributes setProjectionExpression.

Prototype


public void setProjectionExpression(String projectionExpression) 

Source Link

Document

A string that identifies one or more attributes to retrieve from the table.

Usage

From source file:org.iternine.jeppetto.dao.dynamodb.DynamoDBQueryModelDAO.java

License:Apache License

@Override
public Iterable<T> findByIds(ID... ids) throws JeppettoException {
    Collection<Map<String, AttributeValue>> keys = new ArrayList<Map<String, AttributeValue>>();

    for (ID id : ids) {
        keys.add(getKeyFrom(id));/*  ww  w. j a va2 s. com*/
    }

    KeysAndAttributes keysAndAttributes = new KeysAndAttributes().withKeys(keys);

    keysAndAttributes.setConsistentRead(consistentRead);
    keysAndAttributes.setProjectionExpression(projectionExpression);

    if (!projectionExpressionNames.isEmpty()) {
        keysAndAttributes.setExpressionAttributeNames(projectionExpressionNames);
    }

    BatchGetItemRequest batchGetItemRequest = new BatchGetItemRequest()
            .withRequestItems(Collections.singletonMap(tableName, keysAndAttributes));

    return new BatchGetIterable<T>(dynamoDB, persistableEnhancer, batchGetItemRequest, tableName);
}