The DynamoDB mapper will automatically interpret and assign the correct DynamoDB
data type based on the Java type.
If you want to assign the DDB data type specifically, you can use DynamoDBTyped annotation.
Please refer the boolean attribute in the below example.
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBAttribute;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBHashKey;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapperFieldModel.DynamoDBAttributeType;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTable;
import com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBTyped;
@DynamoDBTable(tableName = "yourTableName")
public class MyClass {
String string1;
List<String> stringList;
Boolean flag;
Map<String, String> map;
@DynamoDBHashKey(attributeName = "string1")
public String getString1() {
return string1;
}
public void setString1(String string1) {
this.string1 = string1;
}
@DynamoDBAttribute(attributeName = "stringList")
public List<String> getStringList() {
return stringList;
}
public void setStringList(List<String> stringList) {
this.stringList = stringList;
}
@DynamoDBTyped(DynamoDBAttributeType.BOOL)
public Boolean getFlag() {
return flag;
}
public void setFlag(Boolean flag) {
this.flag = flag;
}
@DynamoDBAttribute(attributeName = "map")
public Map<String, String> getMap() {
return map;
}
public void setMap(Map<String, String> map) {
this.map = map;
}
}