DyanmoDb is storing value 1 instead of boolean value true

VSR :

I have a method which is simply storing flag value true for a particular record. My flag attribute has been defined as Boolean which has value true/false in my DynamoDB database. While running this method, somehow instead of storing true value, it is inserting a new column for the flag attribute as number datatype and writing value 1 instead of true. While debugging I can see it is reading the value as "true" but while writing my guess is it is taking 1 for true and 0 for false, and hence writing 1.

public static ArrayList<UserWishListBuks> removeNotification(int Statusid) {
    AmazonDynamoDBClient ddb = NavigationDrawerActivity.clientManager
            .ddb();
    DynamoDBMapper mapper = new DynamoDBMapper(ddb);
    DynamoDBScanExpression scanExpression = new DynamoDBScanExpression();
    Boolean value = true;
    try{
        PaginatedScanList<UserWishListBuks> result = mapper.scan(
                UserWishListBuks.class, scanExpression);
        for (UserWishListBuks bre : result) {
            if( (bre.getBOOK_STATUS_ID()==(Statusid))   )
            {
                bre.setNOTIFICATION_FLAG(true);
                mapper.save(bre);
            }
        }
    }catch (AmazonServiceException ex) {
        NavigationDrawerActivity.clientManager
                .wipeCredentialsOnAuthError(ex);
    }
    return null;
   }
Moe :

That's expected, have a look at the datatypes docs for dynamodb: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.DataTypes.html

The Java type of Boolean will be stored as a number type in dynamodb, 0 or 1. Alternatively, you can use @DynamoDBNativeBooleanType to map a Java Boolean to the DynamoDB BOOL data type

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=437746&siteId=1