2 回答
- 最新
- 投票最多
- 评论最多
1
This functionality is not yet available for Enhanced Client. I would suggest adding a feature request on the repo: https://github.com/aws/aws-sdk-java-v2/tree/master/services-custom/dynamodb-enhanced
0
To achieve this in DynamoDbEnhancedClient first we need to activate the extension while creating the DynamoDbEnhancedClient bean. Please find the attached code for your reference
Step 1 :-
public DynamoDbClient getDynamoDbClientForEC2() {
return DynamoDbClient.builder()
.region(Region.of(awsRegion))
.credentialsProvider(InstanceProfileCredentialsProvider.create())
.endpointOverride(URI.create(awsDynamoDBEndPoint))
.build();
}
@Bean
@ConditionalOnProperty(prefix = "aws", name = "access.secured", havingValue = "enabled")
public DynamoDbEnhancedClient getDynamoDbEnhancedClientForEC2() {
return DynamoDbEnhancedClient.builder()
.dynamoDbClient(getDynamoDbClientForEC2())
.extensions(AutoGeneratedTimestampRecordExtension.create(), AutoGeneratedUuidExtension.create())
.build();
}
Step 2 :- Finally, you can tell DynamoDbEnhancedClient to autogenerate the key for you in the entity class,
@DynamoDbBean
public class MyEntity {
private String myPartionKey;
@DynamoDbPartitionKey
@DynamoDbAutoGeneratedUuid
public String getMyPartionKey() {
return myPartionKey;
}
}
已回答 4 个月前
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 2 年前
- AWS 官方已更新 2 年前