DyanmoDb存储值1而不是布尔值true
我有一个方法,该方法只是为特定记录存储标志值true.我的标志属性已定义为Boolean,在我的DynamoDB数据库中其值为true/false. 在运行此方法时,将以某种方式代替存储true值,而是将flag属性插入一个新列作为number数据类型,并写入值1而不是true.在调试时,我可以看到它读取的值为"true",但是在写我的猜测时,它需要1表示true,0表示false,因此编写1.
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;
}
That's expected, have a look at the datatypes docs for dynamodb: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBMapper.DataTypes.html
Java的Boolean类型将以数字类型存储在dynamodb,0或1中.
或者,您可以使用@DynamoDBNativeBooleanType
将Java Boolean
映射到DynamoDB BOOL
数据类型
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