Example usage for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression withIndexName

List of usage examples for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression withIndexName

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.datamodeling DynamoDBQueryExpression withIndexName.

Prototype

public DynamoDBQueryExpression<T> withIndexName(String indexName) 

Source Link

Document

Sets the name of the index to be used by this query.

Usage

From source file:com.makariev.dynamodb.preferences.UserPreferenceObjectMapperService.java

License:Open Source License

private List<UserPreference> queryByNames(String firstName, String lastName) {

    DynamoDBQueryExpression<UserPreference> dynamoDBQueryExpression = new DynamoDBQueryExpression<>();
    dynamoDBQueryExpression.withIndexName(UserPreference.NAME_INDEX);

    dynamoDBQueryExpression.withRangeKeyCondition("firstName",
            new Condition().withComparisonOperator(ComparisonOperator.EQ)
                    .withAttributeValueList(new AttributeValue().withS(firstName)));

    dynamoDBQueryExpression.withRangeKeyCondition("lastName",
            new Condition().withComparisonOperator(ComparisonOperator.EQ)
                    .withAttributeValueList(new AttributeValue().withS(lastName)));

    final List<UserPreference> list = mapper.query(UserPreference.class, dynamoDBQueryExpression);

    return list;//  w  w w . j av a 2 s . c  o  m
}