I have a my_table
with a composite sort key made of two combined attributes id
and model_name
(i.e., id_model_name
, similarly from what is done here here and here).
So I created this Java model:
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@DynamoDBTable(tableName = "my_table")
public class TableModel {
private static final String COMPOSITE_KEY_SEPARATOR = "_";
@DynamoDBAttribute(attributeName = "id")
private String id;
@DynamoDBAttribute(attributeName = "model_name")
private String modelName;
@DynamoDBRangeKey(attributeName = "id_model_name")
public String getIdModelName() {
return String.format("%s%s%s", id, COMPOSITE_KEY_SEPARATOR, modelName);
}
// more stuff...
}
However I'm getting:
DynamoDBMappingException: DRTFacet[id_model_name]; could not unconvert attribute
Notice that there is no String idModelName
field, because it could mess up with @AllArgsConstructor
and @Builder
(since it's a derived field). Is it because this field is missing (together with a setter method?). How can I overcome this?
I found out that providing a dummy setter solved the problem:
public void setIdModelName(final String idModelName) {}