Search code examples
spring-bootamazon-dynamodbaws-java-sdk-2.xaws-java-sdk-dynamodb

How to create a boolean datatype in AWS DynamoDB Read/Write operations using DynamoDB table annotations


I have created a class pojo class in java to create/update items in aws dynamodb when i was trying to create/update an item in dynamodb it is working fine but the column created in dynamodb datatype seems to be string instead of boolean. I have tried below annotations but whenever row created datatype seems to be string instead of boolean.

@DynamoDBConvertedBool(value = Format.true_false)
@DynamoDBConvertedBool(DynamoDBConvertedBool.Format.true_false)

DynamoDb class.java

@DynamoDBConvertedBool(value = Format.true_false)
public boolean isDailyconsolidated() {
    return dailyconsolidated;
}

public void setDailyconsolidated(boolean dailyconsolidated) {
    this.dailyconsolidated = dailyconsolidated;
}

@DynamoDBConvertedBool(DynamoDBConvertedBool.Format.true_false)
public boolean isDailyindividual() {
    return dailyindividual;
}

public void setDailyindividual(boolean dailyindividual) {
    this.dailyindividual = dailyindividual;
}

I have given the annotations used and sample attributes used in my class file for reference.


Solution

  • Have you tried using @DynamoDBTyped annotation ?

    @DynamoDBTyped(DynamoDBAttributeType.BOOL)