I have below two test cases implemented to test DynamoDB enhanced library.
Test case 1: Use Get Item on table "digital_form", with PK = "FORM#ABC123" and SK = "INFO#ABC123". which can return result
@Test
public void testGetItemWithPKSK() throws ExecutionException, InterruptedException {
DynamoDbAsyncTable<DigitalFormDao> digitalformTable = dynamoDbEnhancedAsyncClient
.table("digital_form", TableSchema.fromBean(DigitalFormDao.class));
DigitalFormDao form = digitalformTable.getItem(
Key.builder().partitionValue("FORM#ABC123").sortValue("INFO#ABC123").build()).get();
System.out.println(form.getSk());
}
Test case 2: Use Query on same table, with PK= "FORM#ABC123" and SK begin with "INFO". Supposely it will return set of result includes test case 1. However, no result is return.
@Test
public void testQueryWithPKandSKBegin(){
DynamoDbAsyncTable<DigitalFormDao> digitalformTable = dynamoDbEnhancedAsyncClient
.table("digital_form", TableSchema.fromBean(DigitalFormDao.class));
PagePublisher<DigitalFormDao> digitalForms = digitalformTable.query(
r -> r.queryConditional(
sortBeginsWith(k -> k.partitionValue("FORM#ABC123").sortValue("INFO"))));
AtomicInteger atomicInteger = new AtomicInteger();
atomicInteger.set(0);
digitalForms.subscribe(page -> {
DigitalFormDao digitalFormDao = (DigitalFormDao) page.items().get(atomicInteger.get());
System.out.println(digitalFormDao.getSk());
atomicInteger.incrementAndGet();
});
}
Is there some thing wrong in my Query statement?
question from:
https://stackoverflow.com/questions/65641712/dynamodb-enhanced-no-result-from-query 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…