Database Reference
In-Depth Information
If QueryRequest is set to withConsistentRead(true) , then this query will be
performed with a strongly consistent read. If it is set to false , then the query will be per-
formed with eventual consistency.
The query operation will help us to refine items only on primary key attributes (hash and
range). In order to filter the query further, we make use of the query filter.
The following code will create a query filter returning items with Edition equals to 1 ;
usually this query filter will be used on non-key attributes.
//Creates a QueryFilter condition equivalent to Edition = 1
Map<String,Condition> queryFilter = new
HashMap<String,Condition>();
queryFilter.put("Edition", new Condition()
.withComparisonOperator("EQ")
.withAttributeValueList(
new AttributeValue().withN("1")));
The previous code block is exactly the same as the following code block except for the
syntax; both the code blocks will only create a query filter.
//Creates QueryFilterCondition condition equivalent to
Edition = 1
Condition queryFilterCondition = new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("1"));
Map<String, Condition>queryFilter = new HashMap<String,
Condition>();
queryFilter.put("Edition", queryFilterCondition);
The following code creates a query filter with the Edition condition equaling 1 ; further
information about hashKeyCondition and rangeKeyCondition is shown in the
comments.
//Create a HASH key-condition equivalent to BookTitle=SCJP
//Create a RANGE key-condition equivalent to PubDate >
1989-12-28
Map<String, Condition> keyCndtns = new HashMap<String,
Condition>();
Search WWH ::




Custom Search