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

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

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model GetItemRequest 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 T findById(ID id) throws NoSuchItemException, JeppettoException {
    GetItemResult result;/* w w w. j a  v a 2s.c o  m*/

    try {
        GetItemRequest getItemRequest = new GetItemRequest(tableName, getKeyFrom(id), consistentRead);

        getItemRequest.setProjectionExpression(projectionExpression);

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

        result = dynamoDB.getItem(getItemRequest);
    } catch (AmazonClientException e) {
        throw new JeppettoException(e);
    }

    if (result.getItem() == null) {
        throw new NoSuchItemException(entityClass.getSimpleName(), id.toString());
    }

    T t = ConversionUtil.getObjectFromItem(result.getItem(), entityClass);

    ((DynamoDBPersistable) t).__markPersisted(dynamoDB.toString());

    return t;
}