Open
Description
Describe the bug
DynamoDbEnhancedAsyncClient#createTable()
fails to generate secondary indexes that are defined on annotations of the POJO class.
Expected Behavior
The sync version of the DynamoDB enhanced client does create secondary indexes as defined on the POJO class, and so should the async version.
As noted in the Java SDK Developer Guide, beginning with version 2.20.86, createTable()
should automatically generate secondary indexes from data class annotations.
Current Behavior
If i run this:
createTableFuture = messageThreadTable.createTable( );
where the following class was used for schema generation:
Click to see the DynamoDbBean
package org.example.ddbec.model;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSecondaryPartitionKey;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSecondarySortKey;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbSortKey;
import java.util.List;
@DynamoDbBean
public class MessageThread {
private String forumName;
private String subject;
private String message;
private String lastPostedBy;
private String lastPostedDateTime;
private Integer views;
private Integer replies;
private Integer answered;
private List<String> tags;
@DynamoDbPartitionKey
public String getForumName() {
return forumName;
}
public void setForumName(String forumName) {
this.forumName = forumName;
}
// Sort key for primary index and partition key for GSI "SubjectLastPostedDateIndex".
@DynamoDbSortKey
@DynamoDbSecondaryPartitionKey(indexNames = "SubjectLastPostedDateIndex")
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
// Sort key for GSI "SubjectLastPostedDateIndex" and sort key for LSI "ForumLastPostedDateIndex".
@DynamoDbSecondarySortKey(indexNames = {"SubjectLastPostedDateIndex", "ForumLastPostedDateIndex"})
public String getLastPostedDateTime() {
return lastPostedDateTime;
}
public void setLastPostedDateTime(String lastPostedDateTime) {
this.lastPostedDateTime = lastPostedDateTime;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getLastPostedBy() {
return lastPostedBy;
}
public void setLastPostedBy(String lastPostedBy) {
this.lastPostedBy = lastPostedBy;
}
public Integer getViews() {
return views;
}
public void setViews(Integer views) {
this.views = views;
}
@DynamoDbSecondaryPartitionKey(indexNames = "ForumRepliesIndex")
public Integer getReplies() {
return replies;
}
public void setReplies(Integer replies) {
this.replies = replies;
}
public Integer getAnswered() {
return answered;
}
public void setAnswered(Integer answered) {
this.answered = answered;
}
public List<String> getTags() {
return tags;
}
public void setTags(List<String> tags) {
this.tags = tags;
}
public MessageThread() {
this.answered = 0;
this.lastPostedBy = "";
this.forumName = "";
this.message = "";
this.lastPostedDateTime = "";
this.replies = 0;
this.views = 0;
this.subject = "";
}
@Override
public String toString() {
return "MessageThread{" +
"forumName='" + forumName + '\'' +
", subject='" + subject + '\'' +
", message='" + message + '\'' +
", lastPostedBy='" + lastPostedBy + '\'' +
", lastPostedDateTime='" + lastPostedDateTime + '\'' +
", views=" + views +
", replies=" + replies +
", answered=" + answered +
", tags=" + tags +
'}';
}
}
no secondary index are generated:
Reproduction Steps
(See above)
Possible Solution
No response
Additional Information/Context
No response
AWS Java SDK version used
2.26.6
JDK version used
17
Operating System and version
Mac - Sonoma 14.5