我有一个ddb表,在那里我创建了一个gsi。属性如下。我有分区键作为createdby,排序键作为status。
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@DynamoDBTable(tableName = "SomeTable")
public class SchoolInfoObject {
# Some attributes and GSI on them also exists
@DynamoDBIndexRangeKey(globalSecondaryIndexName = "created_by-status-index",
attributeName = "status")
@DynamoDBAttribute(attributeName = "status")
@DynamoDBTypeConvertedEnum
private SomeEnum status;
@DynamoDBIndexHashKey(globalSecondaryIndexName = "created_by-status-index",
attributeName = "created_by")
@DynamoDBAttribute(attributeName = "created_by")
private String createdBy;
}
我使用下面的表达式来获取记录。
SchoolObject hashKObject = new SomeObject();
hashKObject.setCreatedBy(ID);
hashKObject.setStatus(status);
DynamoDBQueryExpression<SchoolInfoObject> queryExpression = new DynamoDBQueryExpression<SchoolInfoObject>()
.withIndexName("created_by-status-index")
.withHashKeyValues(hashKObject)
.withConsistentRead(false);
final List<SomeObject> list = dao.query(SomeObject.class, queryExpression);
其中dao.query调用ddbMap器查询。我面临的问题是,我得到的所有记录都与分区键匹配(排序键没有被比较)。
有人能告诉我我犯了什么错误吗?
暂无答案!
目前还没有任何答案,快来回答吧!