亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

@DynamoDBIndexHashKey 必須指定 HASH GSI 名稱之一

@DynamoDBIndexHashKey 必須指定 HASH GSI 名稱之一

江戶川亂折騰 2021-06-15 17:54:18
我的課程如下@DynamoDBTable(tableName = LogConstant.TableName)public class Journal {@DynamoDBIndexHashKey(attributeName = "event_type")private String eventType;@DynamoDBIndexHashKey(attributeName = "user_id",globalSecondaryIndexName = LogConstant.GlobalUserIdIndex)private String userId;@DynamoDBIndexHashKey(attributeName = "user_identifier", globalSecondaryIndexName = LogConstant.GlobalUserIdentifierIndex)private String userIdentifier;@DynamoDBIndexHashKey(attributeName = "order_id", globalSecondaryIndexName = LogConstant.GlobalOrderIdIndex)private String orderId;@DynamoDBTypeConvertedEnum@DynamoDBAttribute(attributeName = "generated_by")private GenertionType generatedBy;@DynamoDBTypeConvertedEnum@DynamoDBHashKey(attributeName = "interacting_service")private InteractingService interactingSerice;@DynamoDBAttribute(attributeName = "agent")private String agent;@DynamoDBAttribute(attributeName = "content")private String content;@DynamoDBRangeKey@DynamoDBIndexRangeKey(attributeName = "created_at",        globalSecondaryIndexNames = {LogConstant.GlobalUserIdIndex,LogConstant.GlobalUserIdentifierIndex,LogConstant.GlobalOrderIdIndex})private String createdAt;獲取搜索結果的服務是DynamoDBQueryExpression<Journal> expression = new DynamoDBQueryExpression<Journal>()            .withIndexName(LogConstant.GlobalUserIdIndex)            .withConsistentRead(false)            .withHashKeyValues(journal);    TableDescription table = DynamoDbStarter.getDynamoDB().getTable(LogConstant.TableName).describe();    return DynamoDbStarter.getDynamoDBMapper().query(Journal.class, expression);即使插入工作正常但在獲取結果期間我收到異常我有一個哈希鍵作為interacting_service 和范圍鍵作為CreatedDate 的表。我正在嘗試通過 GSI 獲取結果 但不知何故它導致了異常 有人可以看到我做錯了什么嗎
查看完整描述

2 回答

?
心有法竹

TA貢獻1866條經驗 獲得超5個贊

您的異常消息說

@DynamoDBIndexHashKey must specify one of HASH GSI name/names

如果您查看類中的所有@DynamoDBIndexHashKey注釋,您會發現它們都設置了一個值,globalSecondaryIndexName除了 上的注釋eventType。如果eventType應該是 GSI 哈希鍵,則需要設置此值。如果eventType不應該是 GSI 的哈希鍵,那么您需要@DynamoDBIndexHashKey從該字段中刪除注釋。

有關使用的更多詳細信息,請參閱javadoc@DynamoDBImdexHashKey。


查看完整回答
反對 回復 2021-06-23
?
肥皂起泡泡

TA貢獻1829條經驗 獲得超6個贊

它必須是這樣的:


@get:DynamoDBIndexHashKey(attributeName = "product", globalSecondaryIndexName = "product-index")

var product: String? = null

將此也添加到數據庫定義中:


CreateTableRequest()


 ...


 .withGlobalSecondaryIndexes(GlobalSecondaryIndex()

            .withIndexName(PRODUCT_INDEX)

            .withKeySchema(

               KeySchemaElement(PRODUCT, KeyType.HASH),

               KeySchemaElement(PRODUCT_RANGE, KeyType.RANGE))

            .withProjection(Projection().withProjectionType(ProjectionType.ALL))

            .withProvisionedThroughput(ProvisionedThroughput(1L, 2L)))  


查看完整回答
反對 回復 2021-06-23
  • 2 回答
  • 0 關注
  • 416 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號